This module allows authentication against an LDAP directory using the ACL feature. It is included with the DokuWiki release.
Users can log into the wiki using their username and password defined in a LDAP server, adding new users is not supported through the LDAP backend.
Do not report bugs or problems in the wiki! Use the bugtracker, mailinglist and forum instead.
This is an example configuration to set in your conf/local.php to authenticate against your LDAP directory.
$conf['useacl'] = 1; $conf['openregister']= 0; $conf['authtype'] = 'ldap'; #$conf['auth']['ldap']['server'] = 'localhost'; #$conf['auth']['ldap']['port'] = 389; $conf['auth']['ldap']['server'] = 'ldap://server.tld:389'; #instead of the above two settings $conf['auth']['ldap']['usertree'] = 'ou=People, dc=server, dc=tld'; $conf['auth']['ldap']['grouptree'] = 'ou=Group, dc=server, dc=tld'; $conf['auth']['ldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixAccount))'; $conf['auth']['ldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; # This is optional but may be required for your server: #$conf['auth']['ldap']['version'] = 3; # This enables the use of the STARTTLS command #$conf['auth']['ldap']['starttls'] = 1; # This is optional and is required to be off when using Active Directory: #$conf['auth']['ldap']['referrals'] = 0; # Optional bind user and password if anonymous bind is not allowed (develonly) #$conf['auth']['ldap']['binddn'] = 'cn=admin, dc=my, dc=home'; #$conf['auth']['ldap']['bindpw'] = 'secret'; # Mapping can be used to specify where the internal data is coming from. #$conf['auth']['ldap']['mapping']['name'] = 'displayname'; # Name of attribute Active Directory stores it's pretty print user name. #$conf['auth']['ldap']['mapping']['grps'] = array('memberof' => '/CN=(.+?),/i'); # Where groups are defined in Active Directory # Optional debugging #$conf['auth']['ldap']['debug'] = 1;
You can use the version parameter to tell PHP to use Version 3 of the LDAP protocol to connect to your server - default is version 2.
The userfilter defines an LDAP filter which is used to search for a user. The groupfilter is used to fetch the groups a user is in.
The following variables are available for the userfilter and the groupfilter:
| variable | meaning |
|---|---|
| %{user} | The username the user tried to login with |
| %{server} | The server string provided in $conf['auth']['ldap']['server'] |
The groupfilter can also access all the attributes provided in the user object:
| variable | meaning |
|---|---|
| %{dn} | The users dn eg. uid=user,ou=People,dc=server,dc=dk |
| %{uid} | The uid of the user eg. user |
| %{…} |
The mapping is used for directories that uses non “standard” names for attributes, a mapping can be applied a regexp to clean it up before replacing the target variable. For all variables but 'grps' only the first attribute is used to replace the variable if more than one is provided.
| variable | mapping | meaning |
|---|---|---|
| grps | array('memberof' ⇒ '/CN=(.+?),/i') | Replace the content of grps with what is provided in the attribute memberof and apply this regexp /CN=(.+?),/i to every element in it. |
| name | 'displayname' | Replace the content of name with first element of 'displayname' attribute. |
Authentication is done in these steps:
$conf['auth']['ldap'] and to determine the structure of your LDAP server.Below is a list of example configurations used by various users for various LDAP servers. These are examples! Be sure to adjust them to your specific server settings.