LDAP Tokens
Last updated on
22 January 2018
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
Some fields in the ldap modules allow for "ldap tokens". These tokens are replaced by values within an LDAP entry retrieved from the PHP LDAP extension.
Example Use Cases
The following are based on the ldap entry below.
Use Case | Template | Evaluates to |
---|---|---|
ldap server mail template | [cn]@myuniversity.edu |
jdoe@myuniversity.edu |
ldap server mail template | [cn]@[dc:1].edu |
jdoe@myuniversity.edu |
Example Illustrating Derivation of Token Values
An ldap entry arrray such as:
'dn' => 'cn=jdoe,ou=campus accounts,ou=toledo campus,dc=ad,dc=myuniveristy,dc=edu',
'mail' => array( 0 => 'jdoe@myuniversity.edu', 'count' => 1),
'sAMAccountName' => array( 0 => 'jdoe', 'count' => 1),
would have the following tokens available for its templates:
-- from dn attribute
[cn] = jdoe
[cn:0] = jdoe
[cn:last] => jdoe
[ou] = campus accounts
[ou:0] = campus accounts
[ou:1] = toledo campus
[ou:last] = toledo campus
[dc] = ad
[dc:0] = ad
[dc:1] = myuniveristy
[dc:2] = edu
[dc:last] = edu
-- derived from other attributes
[mail] = jdoe@myuniversity.edu
[mail:0] = jdoe@myuniversity.edu
[mail:last] = jdoe@myuniversity.edu
[samaccountname] = jdoe
[samaccountname:0] = jdoe
[samaccountname:last] = jdoe
Additional Example Tokens
In the server test page admin/config/people/ldap/server/[server_id]/test
you can see the tokens and sample values when you enter a test username and submit the form.
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion