This plugin allows authentication against an LDAP directory using the ACL feature.
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.
Before this plugin can be used, you need to ensure the LDAP PHP module is installed, then setup some settings:
authldap
.The version supplied on this page shows a basic setup, this needs to be modified to your own database setup. Different setups are provided.
Save the configuration settings to the conf/local.protected.php
file to protect the settings against changes via Config Manager.
Adding and changing users is not supported through this plugin. So the User Manager, self registration of users and password reset are disabled by this plugin.
The backend will be enabled with the authtype configuration option by selecting authldap
this is part of “Authentication settings” section.
In the “Plugin Settings” are settings for the authLDAP plugin. Here you define your LDAP server and connection settings.
There are more general authentication related settings available too.
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.
This is an example configuration to set via the Config Manager or in your conf/local.protected.php
to authenticate against your LDAP directory.
<?php /** * Protected settings * LDAP configuration example */ $conf['useacl'] = 1; //enable ACL $conf['authtype'] = 'authldap'; //enable this Auth plugin #$conf['plugin']['authldap']['server'] = 'localhost'; #$conf['plugin']['authldap']['port'] = 389; $conf['plugin']['authldap']['server'] = 'ldap://server.tld:389'; #instead of the above two settings $conf['plugin']['authldap']['usertree'] = 'ou=People, dc=server, dc=tld'; $conf['plugin']['authldap']['grouptree'] = 'ou=Group, dc=server, dc=tld'; $conf['plugin']['authldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixAccount))'; $conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(memberUID=%{user}))'; $conf['plugin']['authldap']['attributes'] = array('cn', 'displayname', 'mail', 'givenname', 'objectclass', 'sn', 'uid', 'memberof'); # This is optional but may be required for your server: #$conf['plugin']['authldap']['version'] = 3; # This enables the use of the STARTTLS command #$conf['plugin']['authldap']['starttls'] = 1; # This is optional and is required to be off when using Active Directory: #$conf['plugin']['authldap']['referrals'] = 0; # Optional bind user and password if anonymous bind is not allowed #$conf['plugin']['authldap']['binddn'] = 'cn=admin, dc=my, dc=home'; #$conf['plugin']['authldap']['bindpw'] = 'secret'; # Limit search scope for user and group searches (sub|one|base) #$conf['plugin']['authldap']['userscope'] = 'sub'; #$conf['plugin']['authldap']['groupscope'] = 'sub'; # Optional debugging #$conf['plugin']['authldap']['debug'] = 1; #### not available via Config Manager #### # Mapping can be used to specify where the internal data is coming from. #$conf['plugin']['authldap']['mapping']['name'] = 'displayname'; # Name of attribute the directory stores its pretty print user name. #$conf['plugin']['authldap']['mapping']['grps'] = array('memberof' => '/CN=(.+?),/i'); # Where groups are defined in directory
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['plugin']['authldap']['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 search scope (depth) can be limited to sub
, one
and base
using the optional userscope
and groupscope
parameters. They default to sub
. Setting them to more limited searches can improve performance.
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. |
attributes is an array that defines what attributes needs to be fetched during a LDAP user search.
Authentication is done in these steps:
$conf['plugin']['authldap']
and to determine the structure of your LDAP server.$conf['plugin']['authldap']['version'] = 3;