# Appendix B: Sample LDAP CR
A sample Custom Resource (CR), playbooks/roles/ldap/vars/ldap_cr.yml, is included in the solution. It shows
the parameters and example values for an LDAP identity provider.
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: msad
mappingMethod: claim
type: LDAP
ldap:
attributes:
id:
- name
email:
- UserPrincipalName
name:
- cn
preferredUsername:
- sAMAccountName
bindDN: "{{ ldap_bind_user_dn }}"
bindPassword:
name: ldap-secret
ca:
name: ca-config-map
insecure: false
url: "ldaps://mars-adds.am2.cloudra.local/CN=Users,DC=am2,DC=cloudra,DC=local?sAMAccountName??(objectClass=person)"
The identity provider name is prefixed to the returned user ID to form an identity name. In this instance, the example name
msadis used to indicate Microsoft Active Directory is being used. After the identity provider has been set up, you can use theoc get identitiescommand to see the prefix in use:$ oc get identities NAME IDP NAME IDP USER NAME USER NAME msad:YWRvY3AgYWRtaW4x msad YWRvY3AgYWRtaW4x adocpadmin1 msad:YWRvY3AgdXNlcjE msad YWRvY3AgdXNlcjE adocpuser1The identity provider name is also displayed as an option when logging in to the web console.
The
bindDNparameter is the name of the LDAP user required to perform the search. This value is actually defined in thegroup_vars\all\vars.ymlfile using the variableldap_bind_user_dn.The
bindPasswordis stored in a secret which is created when you run theplaybooks\ldap.ymlplaybook. The underlying password itself should be strored ingroup_vars/all/vault.ymlas the value of the variablevault.ldap_bind_user_password.The
mappingMethoddefines how new identities are mapped to users when they log in. The valueclaimwill cause a new user to be created if one does not already exist with that name. It will fail if a user with that user name is already mapped to another identity.The
urlis an RFC 2255 URL, which specifies the LDAP host and search parameters to use. The syntax of the URL is:ldap://host:port/basedn?attribute?scope?filter
More information on configuring the custom resource is available at https://docs.openshift.com/container-platform/4.2/authentication/identity_providers/configuring-ldap-identity-provider.html.