Provides authentication against a Microsoft Active Directory
This auth backend allows DokuWiki to authenticate against an Active Directory Server.
While Active Directory authentication can be set up with the bundled authLDAP plugin, it should be easier to do with this dedicated AD auth plugin. It makes use of the excellent adLDAP library and is based on the work by James Van Lommel. You do not need to download the adLDAP library yourself, it is included with DokuWiki.
In addition it allows the use of NTLM and Kerberos based Single-Sign-On .
Before this plugin can be used, you need to setup some settings:
authad
.
Save the configuration settings to the conf/local.protected.php
file to protect the settings against changes via Config Manager.
Modification of users and its groups can be done in the User manager. Only modifications are possible, adding new users is not possible with authAD. Also self registration by users is disabled by the authAD plugin. At the moment the wiki cannot check Active Directory password policy, so better you disable the action password reset resendpwd
or if possible modify your AD password policy.
Your server configuration must meet the requirements of the adLDAP PHP library.
If you're using Apache on Ubuntu or Debian, just install the php5-ldap
package. If you're using Apache on another distro, follow this guide1). Installing php5-ldap
also works on SLES. If you're using Arch Linux, install the php-ldap package with pacman.
For MS IIS7 server php-ldap
and php-openssl
extensions needs to be installed (the second one only when SSL support required). For php-openssl
dependency dlls ssleay32.dll
and libeay32.dll
needs to be available in your system too, you will need to make sure they are in a folder that is in the system path or just drop them off in the windows\system32 folder. When accessing AD using SSL, you must create file ldap.conf
in C:\OpenLDAP\sysconf
with line TLS_REQCERT never
. which disables AD certificate checking when making LDAP call.
WARNING! This could lead to Man-In-The-Middle attacks, so probably better solution is configure valid certificate using this file (more on http://linux.die.net/man/5/ldap.conf).
If you're using Debian, just install the php5-ldap
package.
Installing under Nginx on Ubuntu 14 requires php5-ldap. Follow the Nginx php setup instructions here: Dokuwiki Nginx Config. The user needs only to set account_suffix, base_dn, and domain_controllers. For domain controller, ldaps:<server> and ldap:<server> work. These modifications were made in local.php than moved to local.protected.php ex:
$conf['plugin']['authad']['account_suffix'] = '@ad.something.edu'; $conf['plugin']['authad']['base_dn'] = 'dc=ad,dc=something,dc=edu'; $conf['plugin']['authad']['domain_controllers'] = 'ldaps://ad.something.edu';
If you're using a web server other than Apache, Nginx, or IIS7, you have to figure it out yourself. :( Please update this article if you succeed.
The backend will be enabled with the authtype configuration option by selecting authad
which is part of “Authentication Settings” in the Configuration Manager, or you could add a corresponding line to the conf/local.protected.php
file to save the setting protected for changes.
In the “Plugin Settings” are settings for the authAD plugin. Here you define your AD server and connection details.
There are more general authentication related settings available too.
You can use the Configuration Manager to configure the plugin. However to avoid having them overridden by the config manager it is recommended to place the configuration in conf/local.protected.php
.
You probably want to set at least these options:
<?php // general DokuWiki options $conf['useacl'] = 1; $conf['authtype'] = 'authad'; // configure your Active Directory data here $conf['plugin']['authad']['account_suffix'] = '@my.domain.org'; $conf['plugin']['authad']['base_dn'] = 'DC=my,DC=domain,DC=org'; $conf['plugin']['authad']['domain_controllers'] = 'srv1.domain.org, srv2.domain.org'; //multiple can be given
Optionally the following parameters can be given:
$conf['plugin']['authad']['admin_username'] = 'root'; $conf['plugin']['authad']['admin_password'] = 'pass'; $conf['plugin']['authad']['sso'] = 1; $conf['plugin']['authad']['real_primarygroup'] = 1; $conf['plugin']['authad']['use_ssl'] = 1; // Don't have ssl/tls options enabled at the same time. $conf['plugin']['authad']['use_tls'] = 1; // Only one of them. $conf['plugin']['authad']['debug'] = 1; $conf['plugin']['authad']['recursive_groups'] = 1; // If number of groups in AD is large switching to 0 will improve performance, but indirect membership will not work $conf['plugin']['authad']['additional'] = 'department,office'; // additional attributes to fetch // warn user about expiring password this many days in advance (in version 2012-03-10 and higher): $conf['plugin']['authad']['expirywarn'] = 5;
admin_username
and admin_password
are e.g. required to enable user email subscriptions. This account binds to the AD for querying user details.
Use this code snippet in local.protected.php to set superuser rights:
$conf['manager'] = '@LDAPGROUPNAME'; $conf['superuser'] = '@LDAPGROUPNAME';
AD group names should be preceded with “@” and all spaces should be replaced with underscores. For example, if my AD group is called “Internal DokuWiki Admins”, it should be “@Internal_DokuWiki_Admins” in DokuWiki. Any additional LDAP syntax is unneeded (e.g. all “CN=”, “DN=”, etc.). Only the name of the group is needed.
Any other options given in $conf['plugin']['authad']
are directly passed to the adldap library. Please refer to the adLDAP documentation2) for a detailed description of what other options might be available.
In combination with Single-Sign-On, you can also add Windows domain specific setups. E.g. to authenticate against different Active Directory Servers depending on the NTLM or Kerberos Domain of a given user. The (lowercased) Domain just has to be used as a subkey to the $conf['plugin']['authad']
setting. E.g. to identify all users coming from the Foobar
Windows Domain using a non-default AD Server and user just put the following additional lines into your config:
$conf['plugin']['authad']['foobar']['account_suffix'] = '@foobar.domain.org'; $conf['plugin']['authad']['foobar']['base_dn'] = 'DC=foobar,DC=domain,DC=org'; $conf['plugin']['authad']['foobar']['domain_controllers'] = 'otherad.domain.org'; $conf['plugin']['authad']['foobar']['admin_username'] = 'otherroot'; $conf['plugin']['authad']['foobar']['admin_password'] = 'otherpass';
Please note that the subkey is only needed for the second and following domains. The first domain needs to be specified without a subkey. Otherwise the domain selector won't show up.
You can set a default domain as option, used as fallback when no domain is given:
$conf['plugin']['authad']['domain'] = 'foobar';
When you configure more than one domain, a domain selection is shown in the login form.
If you have an organisation with multiple DCs under a single parent, you may need to connect to port 3268, rather than the default port 389. Otherwise, users from the remote DC may not show up as members of any groups. The easiest way to do this is to add the following parameter to your local.protected.php
$conf['plugin']['authad']['ad_port'] = 3268;
Users can change their user details (name, email and passwords) using the profile button. This may require to set up a privileged user through the admin_username
and admin_password
options. Password changing is only supported via SSL or TLS. See LDAP over SSL3) in the adLDAP documentation.
Please note that DokuWiki's auto generated passwords do not match with the Active Directory default password policy. Either adjust your AD password policy or disable the “Forget Password” option using the disableactions config option.
Group and user names are cleaned up internally so they might differ from what is configured in your Active Directory server. Spaces are replaced with underscore and backslashes and hash symbols are removed.
Example: Domain Users
becomes Domain_Users
in DokuWiki. When you edit your ACLs manually, remember the correct encoding: Domain%5fUsers
. The “%5f” represents an underscore.
Keep this in mind when specifying users and groups in ACL setup or configuration.
Single Sign On (SSO) means that DokuWiki will use your Windows login name to identify you without the need for you to log in. This relies on the server setting the REMOTE_USER
environment variable. The ad backend then will use this username to fetch additional data like your group membership.
To make this work you need to enable the sso
setting in local.protected.php
and most probably also need to setup a management account with enough permissions to fetch the user info:
$conf['plugin']['authad']['sso'] = 1; $conf['plugin']['authad']['admin_username'] = 'MyManager'; $conf['plugin']['authad']['admin_password'] = 'ManagerPass';
Additonally some settings have to be made for your server and the used Browser.
Note: Once Windows Authentication is enabled, all write and read access is done as the authenticated users which requires either very permissive permissions on the filesystem or another setting in IIS. The latter is recommended. Simpley switch system.webServer/serverRuntime/authenticatedUserOverride
to UseWorkerProcessUser
in the IIS Configuration Editor as oulined as Option #4 in this Blog Post.
First configure IIS to use the Windows Logon for authentication (see screenshots):
inetmgr
Then make sure NTLM is used as authentication protocol. This has to be done on the commandline:
cmd
cd \Inetpub\Adminscripts
cscript adsutil.vbs get w3svc/NTAuthenticationProviders
cscript adsutil.vbs set w3svc/NTAuthenticationProviders “NTLM”
LoadModule sspi_auth_module modules/mod_auth_sspi.so <Directory "c:/wamp/www/"> AuthName "My Intranet" AuthType SSPI SSPIAuth On SSPIAuthoritative On require valid-user </Directory>
LoadModule sspi_auth_module modules/mod_auth_sspi.so <Directory "c:/wamp/www/"> AuthName "My Intranet" AuthType SSPI SSPIAuth On SSPIAuthoritative On require valid-sspi-user </Directory>
sudo apt-get install libapache2-mod-python
wget https://github.com/Legrandin/PyAuthenNTLM2/zipball/master
sudo python setup.py install
<Directory /var/lib/some_directory> AuthType NTLM AuthName !!DOMAIN!! require valid-user PythonAuthenHandler pyntlm PythonOption Domain !!DOMAIN!! PythonOption PDC !!PRIMARY_DOMAIN_CONTROLLER!! PythonOption BDC !!BACKUP_DOMAIN_CONTROLLER!! </Directory>
Note: ap_requires is deprecated in Apache 2.4, this NTLM method no longer works as described.
This setup enables an Apache Server on Linux to verify Kerberos Tickets against an Active Directory server.
Good references for Apache/Kerberos can be found at
Microsoft has a good (albeit somewhat outdated) article series here.
The following examples assume your wiki to be running on dokuwiki.yourdomain.com
, with your Active Directory server running at dc1.yourdomain.com
;
Note: Kerberos is case sensitive, if it is all caps - it should be!
/etc/krb5.conf
:[logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = YOURDOMAIN.COM ticket_lifetime = 24h forwardable = yes [realms] YOURDOMAIN.COM = { kdc = dc1.yourdomain.com admin_server = dc1.yourdomain.com default_domain = yourdomain.com } [domain_realm] dokuwiki.yourdomain.com = YOURDOMAIN.COM .yourdomain.com = YOURDOMAIN.COM yourdomain.com = YOURDOMAIN.COM [appdefaults] pam = { debug = false ticket_lifetime = 36000 renew_lifetime = 36000 forwardable = true krb4_convert = false }
kinit username@YOURDOMAIN.COM klist kdestroy
If you get any errors here, make sure your DNS setup is working and you wrote all marked as “YOURDOMAIN.COM” hosts in uppercase in your krb5.conf. Try resolve every hostname manually.
ktpass -princ HTTP/dokuwiki.yourdomain.com@YOURDOMAIN.COM -mapuser name_of_ad_user_you_have_created@yourdomain.com -crypto RC4-HMAC-NT -ptype KRB5_NT_PRINCIPAL -pass the_ad_users_password -out dokuwiki.HTTP.keytab
kinit -k -t /etc/httpd/confo/dokuwiki.HTTP.keytab HTTP/dokuwiki.yourdomain.com kdestroy
If this doesn't work, there is no need to continue. Fix this first.
<Directory "/var/www/html/dokuwiki"> # Kerberos Auth AuthType Kerberos KrbAuthRealms YOURDOMAIN.COM KrbServiceName HTTP/dokuwiki.yourdomain.com Krb5Keytab /etc/httpd/conf/dokuwiki.HTTP.keytab KrbMethodNegotiate on KrbMethodK5Passwd on require valid-user </Directory>
setspn -X
Remove any duplicates found.
Your browser needs to be setup to forward authentication info to the Webserver.
Activate SPNEGO in Internet Explorer by:
http://intranet.company.com,http://email.company.lan
Notice that you can use a comma separated list in this field.
Some plug-ins may not gracefully work once you've switched over to the ad auth backend. Specifically, pulling the user's display name will not work if you don't provide valid authentication information. One such plugin is WikiStatistics, where a simple workaround to only display the username can be employed.
Due to missing support for paged queries in PHP's LDAP extension6), plugins that try to get all users from the auth backend will fail if you use authAD plugin and have more than 1000 objects in Active Directory. One example is the IssueTracker plugin.