[Show/Hide Right Column]

Print

Support forum

http://tikiwiki.org/forum17

Bug reports and feature requests

http://dev.tikiwiki.org/LDAP

LDAP Authentication up to Tiki 3.X

LDAP Pear::Auth General Settings Overview

Tiki can authenticate users using a LDAP server via Pear::Auth (see http://pear.php.net/package-info.php?package=Auth) . The following settings only make sense, if you have set "Authentication method" to " Tiki/Pear::Auth " in the above dialog. Tiki then uses the LDAP server in addition to its own user database (users_users) to authenticate users. Your Php must have ldap support on (debian: php4-ldap, php5-ldap, ....)

Image
Image

Create user if not in Tiki?If a user was authenticated via LDAP, but not found in the Tiki user database, Tiki will create an entry in its user database if this option is checked. If this option is disabled, this user wouldn't be able to log in
Create user if not in Auth?If a user was authenticated by Tiki's user database, but not found on the LDAP server, Tiki will create an LDAP entry for this user. See Pear::Auth on how an entry is created.
Just use tiki auth for admin?If this option is set, the user "admin" will be authenticated by only using Tiki's user database and not via LDAP. This option has no effect on users other than "admin".
LDAP HostThe hostname or ip address of you LDAP server (usually localhost).
LDAP PortThe port number your LDAP server uses (389 is the default).
LDAP ScopeSearch scope (base = Base object search, one = one-level search, sub = Subtree search (default) ) used during authentication for finding a user on the LDAP server.
LDAP Base DNBase DN of the LDAP server. If you leave this empty, Pear::Auth will try to query your LDAP server for its base DN. Example: dc=my-company,dc=com
LDAP User DNRDN to prepend to the base DN when searching for a user. Example: ou=People will search in ou=People,dc=my-company,dc=com
LDAP User attributeAttribute that contains the username. (Note: for Active Directory try UserAttribute: sAMAccountName)
LDAP User OCObject class an entry must have when searching for a user. This is mandatory ! If you dont know what to fill in, use * (an asterix)
LDAP Group DNRDN to prepend to the base DN when searching for a user. Example: ou=Groups will search in ou=Groups,dc=my-company,dc=com
LDAP Group AttributeAttribute that contains the group name. Example cn
LDAP Group OCObjectclass used to create groups. Example groupOfUniqueNames would result in a group search usinf the filter (objectclass=groupOfUniqueNames)
LDAP Member AttributeAttribute used to retreive group members. Example uniqueMember will result in retrieval of all uniqueMembers from a groupOfUniqueNames
LDAP Member Is DNDefines whether member attribute retrieved using LDAP Member Attribute is full DN (y/n)
LDAP Admin UserDN of the entry to use to bind to the LDAP server for user creation. While authentication works without binding as a privileged DN, creation of an entry usually does not. This admin DN is only used when creating user entries on the LDAP server (i.e. only if the option Create user if not in Auth is checked). Authentication works without an admin DN ( Pear::Auth will try to bind using the username/password to authenticate). Note: When using Active Directory as the LDAP server, you usually have to specify an Admin user/PW. This is due to AD's default restriction that doesn't allow anonymous searches. In this case the user does not need to be an administrative user. A regular user account will suffice.
LDAP Admin PwdPassword for the above DN.
LDAP Version Usually 3

The LDAP Group and LDAP Member settings are currently not used by Tiki (as of 1.10 rc).

If your admin page does not contain all the fields listed above, reference LDAPUseInPriorVersions for information on how to modify versions of tikiwiki prior to 1.9.8 to use LDAP.

LDAP Pear::Auth Troubleshooting

You can verify your connection by editing the file \tiki\lib\pear\Auth\Container\LDAP.php in line 441 (for tw < 4) from Image

$this->options['debug']       = false;
to Image
$this->options['debug']       = true;
After the login you see a screen with a successful binding to the AD/LDAP-Server Image
281: Connecting with host:port
288: Successfully connected to server
292: Switching to LDAP version 3
306: Switching LDAP referrals to true
312: Binding with credentials
325: Binding was successful
548: UTF8 encoding username for LDAPv3
574: Searching with ldap_search and filter (&(sAMAccountName=exampleuser)(objectClass=*)) in ou=europe,dc=xnet,dc=oe,dc=examplehost
581: User was found
636: Bind as CN=exampleuser,OU=users,OU=ode,OU=europe,DC=xnet,DC=oe,DC=examplehost
640: Bind successful
650: Authenticated

Be ware that after your troubleshooting you must switch off the debug option to login.

LDAP Authentication in Tiki 4.0

Changes

The LDAP Authentication part has been rewritten in Tiki 4.0. Tiki no more uses PEARs Auth due to the lack of flexibility and missing features - PEARs Auth is not intended to be able to fetch any other LDAP entries than the user entry. Now it uses PEAR LDAP2.

List of changes:

  • The words "PEAR Auth" and "Auth" have been replaced by "LDAP" in code and web frontend
  • A proxy user (ldap admin) is no more needed to authenticate
  • You can add more redundant LDAP servers in your configuration
  • The use of ssl or tls is supported now (needs some more testing)
  • You can specify the type of LDAP Server (Active Directory, Openldap, ...)
  • User and Group information can be replicated to tiki on every user login. Therefore you can reuse data already present in your LDAP directory
  • Users replicated from LDAP have now disabled tiki passwords to avoid having ghost users in tiki that are deleted in LDAP

How it works

If a user enters his username and password in tiki, a binddn is created and together with the password used to authenticate the user at the ldap server. Once authenticated the user is allowed to read data from the ldap server. Especially he usually can read his own data and the ldap group information. These data are used to create the user and group in tiki. The user has the tiki password disabled. He only can login via LDAP. On subsequent logins, the data are synchronized from LDAP to tiki (not the other direction!). The replicated data can be at the moment:

  • Users full name
  • Users email address
  • Users country information
  • Users group membership
  • Group name and description

So if you change any of the above information in LDAP, the data are synchronized the next time the user logs into tiki. You can even change group membership in LDAP and it gets sychronized to tiki. What is not replicated to tiki are object (usr/group) deletions.

Group membership and permissions

One useful use of LDAP with groups is to give users from specific groups more permissions. Since every user created in tiki is assigned to the build in group "Registred", you should give "Registred" the same permissions like "Anonymous". You may want to give some LDAP usergroups special permissions. Let one user of that group login to tiki to automatically create the group. Then assign permissions to that group.

How anonymous binding works

- connect anonymously to the LDAP server - get the user DN - authenticate the user by binding with the server as DN + password

Settings

Create user if not in Tiki?If a user was authenticated via LDAP, but not found in the Tiki user database, Tiki will create an entry in its user database if this option is checked. If this option is disabled, this user wouldn't be able to log in
Create user if not in LDAP?If a user was authenticated by Tiki's user database, but not found on the LDAP server, Tiki will create an LDAP entry for this user. As of time of writing, this is not yet implemented, and this option will probably no more offered in future.
Use Tiki authentication for Admin loginIf this option is set, the user "admin" will be authenticated by only using Tiki's user database and not via LDAP. This option has no effect on users other than "admin".
Use Tiki authentication for users created in tikiIf this option is set, users that are created using Tiki are not authenticated via LDAP
HostsThe hostnames, ip addresses or URIs of your LDAP servers. Separate multiple entries with Whitespace or ','. If you use URIs, then the settings for Port number and SSL are ignored. Example: "localhost ldaps://master.ldap.mydomain.org:63636" will try to connect to localhost unencrypted and if if fails it will try the master ldap server at a special port with ssl.
PortThe port number your LDAP server uses (389 is the default, 636 if you check ssl).
Write LDAP debug Information in Tiki LogsWrite debug information to tiki logs. For production sites uncheck this!
LDAP Bind TypeHere you can control how your bind DN is constructed.
Search ScopeSearch scope (base = Base object search, one = one-level search, sub = Subtree search (default) ) used after authentication for getting user and group information
LDAP Version Usually 3
Base DNBase DN of the LDAP server. Gets appended to bind DN, user DN and group DN. Example: dc=my-company,dc=com
User DNRDN to prepend to the base DN when searching for a user. Example: ou=People will search in ou=People,dc=my-company,dc=com
User attributeAttribute that contains the username. (Note: for Active Directory try UserAttribute: sAMAccountName)
User OCObject class an entry must have when searching for a user. This is mandatory ! If you dont know what to fill in, use * (an asterix)
Realname attributeAttribute that holds the real name of the user.
Country attributeAttribute that holds the country information of the user.
E-mail attributeAttribute that holds the email of the user.
Group DNRDN to prepend to the base DN when searching for a user. Example: ou=Groups will search in ou=Groups,dc=my-company,dc=com
Group AttributeAttribute that contains the group name. Example cn
Group Description AttributeAttribute that contains the group description
Group OCObjectclass used to create groups. Example groupOfUniqueNames would result in a group search using the filter (objectclass=groupOfUniqueNames)
Member AttributeAttribute used to retreive group members. Example uniqueMember will result in retrieval of all uniqueMembers from a groupOfUniqueNames
Member Is DNDefines whether member attribute retrieved using LDAP Member Attribute is full DN (y/n)
Group attribute in user entryIf the members of a group cannot be found in the group entry, then use this attribute in the users entry to get group information. Example: gidNumber
Group attribute in group entryUsually empty. Used to search the group entries. Usually the same like the line above - and then you can leave the field empty.
LDAP Admin UserDN of the entry to use to bind to the LDAP server for user creation. While authentication works without binding as a privileged DN, creation of an entry usually does not. This admin DN is only used when creating user entries on the LDAP server (i.e. only if the option Create user if not in Auth is checked). Authentication works without an admin DN.
LDAP Admin PwdPassword for the above DN.

How to know which LDAP Bind Type you need to use

- Active Directory bind method will build a RDN like where your basedn is (dc=domain, dc=com) and username is your username - Plain bind method will build a RDN username - Full bind method will build a RDN like userattr=username, userdn, basedn where userattr is replaced with the value you put in 'User attribute', userdn with the value you put in 'User DN', basedn with the value with the value you put in 'base DN' - Openldap bind method will build a RDN like cn=username, basedn - anonymous bind method will build an empty RDN

If you do not know, the best is to use a tool to access the directory like Apache Directory Studio If you can enter your directory with your email, it is probably an Active Directory If you can access with your username, it can be plain, full, or openldap After with your tool navigate to select a user, the DN of the user will be shown and you will be able to guess the method

Some tips: - You can not build a RDN/DN like this "sAMAccountName=username,dc=domain,dc=com". If you would like to do so because the CN is the real name and not the username, it is probably because you have choosen the wrong bind method (it can be an active directory method) - Use always he search scope subtree at the beginning - as soon as you are sure of your parameters use antoher method for performance

How to get the email and other attributes back in tikiwiki

Tiwiki builds another DN to get the attributes. This time, tikiwiki uses a search and not a bind. The DN is userattr=username, userdn, basedn where userattr is the attribute you put in 'User Attribute', username is the username, userdn the value you put in 'User DN' and basedn is the value you put in basedn. This time you can use sAMAccountName in the attribute (it is a search not a bind). Then put the attribute name you see in the DN taht contains the mail

Examples

Unix

These settings should work on most Unix systems that use LDAP for authentication and as information store:

LDAP Bind TypeDefault
Base DNdc=yourdomain,dc=tld
User DNou=users
User attributeuid
User OCinetOrgPerson
Realname attributecn
E-Mail attributemail
Group DNou=usergroups
Group attributecn
Group OCgroupOfNames
Member attributemember
Member is DNyes

Active Directory

LDAP Bind TypeActive Directory
Base DNdc=yourdomain,dc=tld
User DNcn=users
User attributesAMAccountName
User OCuser
Realname attributedisplayName
E-Mail attributeprobably userPrincipalName - not sure if you use exchange
Group DN
Group attributecn
Group OCgroup
Member attributemember
Member is DNyes

Zimbra LDAP

LDAP Bind TypeDefault
Base DNdc=domain,dc=com
User DNou=people
User attributeuid
User OC*
Realname attributedisplayName
E-mail attributemail
Further Instructionshttp://wiki.zimbra.com

Debugging

Check the box at "Write LDAP debug Information in Tiki Logs:" and try to authenticate in another browser. Check Tiki Logs (tiki-syslog.php) to see what went wrong.

ATTENTION: Uncheck the debug settings once you managed to set up your connection. Your logs will get flooded else!

If this even does not help, you can use this code to check whats wrong:

ldap connect test
<?php
$con = ldap_connect('ldap://my_hostname:389');
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($con, LDAP_OPT_REFERRALS, false);
$dn = 'cn=username,dc=domain,dc=tld';
if(ldap_bind($con, $dn,'verrry_secret'))) {
  echo "connec succeeded";
  //and if you want to test the mail
  $filter = '(objectClass=*)';
  $just = array('mail'); // adapt the attribute name
  $sr = ldap_search($con, $dn, $filter, $just);
  $info = ldap_get_entries($con, $sr);
  print_r($info);
} else {
  echo "Oops!";
}
?>

Replace Hostname, Port, binddn and password and run it with php connect.php

Present the output your LDAP Administrator.

Useful tool: Apache Directory studio

Common Problems and Workarounds

Certificate Problems

If you use certificates on LDAP server side where the root certificate is not trusted, you should put the root or CA certificate somewhere at your tiki webserver and let /etc/openldap/ldap.conf know where it is. Use parameters TLS_CACERTDIR and TLS_CACERT to point it to the root or CA certificate.

If you use self signed certificates you can also simply disable certificate checking by setting TLS_REQCERT to "never" in /etc/openldap/ldap.conf.

See the manpage of "ldap.conf" to get more information.

Aliases


Contributors to this page: deus54 points  , xavidp901 points  , system , sylvie4333 points  , Rick7121 points  , Florian Gleixner14 points  , pow25 points  , mlpvolt1895 points  , Michael Davey15 points  , Marc Laporte5511 points  , Nelson393 points  , kai_drews4 points  , Greg Martin49 points  , gillesm60 points  , dthacker1330 points  , Carsten Schmitz40 points  , Damian Parker14 points  and Gary Cunningham-Lee996 points  .
Page last modified on Friday 26 March, 2010 14:13:15 UTC by deus54 points .


Here are example settings taken from what I'm using to authenticatte against my AD. The only "tricky" part was setting up a service account as AD requires a login before any authentication query will be processed. As we have OU Admin rights, this wasn't a major problem.

Create user if not in Tiki: checked Just user Tiki auth for admin: checked LDAP Host: ad-ldap.domain.tld LDAP Port: 3268 LDAP Scope: sub LDAP Base DN: dc=domain,dc=tld LDAP User Attribute: cn LDAP User OC: * LDAP Member is DN: n LDAP Admin User: LDAP Admin Pwd: **********



> Here are example settings taken from what I'm using to authenticatte against my AD. The only "tricky" part was setting up a service account as AD requires a login before any authentication query will be processed. As we have OU Admin rights, this wasn't a major problem. > > Create user if not in Tiki: checked > Just user Tiki auth for admin: checked > LDAP Host: ad-ldap.domain.tld > LDAP Port: 3268 > LDAP Scope: sub > LDAP Base DN: dc=domain,dc=tld > LDAP User Attribute: cn > LDAP User OC: * > LDAP Member is DN: n > LDAP Admin User: > LDAP Admin Pwd: **********

This configuration worked for me with the following modifications:

LDAP Port: 389 UserAttribute: sAMAccountName

Hope this helps.

_KJH



Unfortunately, I'm having to host externally to the AD server, so I need to do it by domain. Someone else pointed me toward the code I needed to modify, so I got it working (one-line change).

Thanks,

e.d.



can you help me in solving my ldap problem.. I have listed it in mailing list http://sourceforge.net/mailarchive/forum.php?thread_id=7980940&forum_id=20000 http://sourceforge.net/mailarchive/forum.php?thread_id=7994849&forum_id=20000

thanks in advance




The "Validate email address (may not work) option needs documentation.

It would also be helpful if there were a way to restrict accounts by email domain.

e.d.




This doc is missing several fields compared to my 1.8.6 install

LDAP Group DN: similar to User DN but both should be called User or Group RDN LDAP Group Attribute: LDAP Group OC: LDAP Member Attribute: LDAP Member Is DN:

\\Greg




I can only get LDAP to work if my passwords are cleartext. How do I tell tiki that my LDAP passwords are crypt or md5?

\\Greg




Hi everybody. I need help with the configuration of tikiwiki and active directory. I'm using the followings: PHP Version 5.1.4 Apache/2.2.2 (Win32) running on windows server 2003 Active Directory on Microsoft sever 2003 tikiwiki-1.9.3.2.

I tried to use the examples of configuration found in tikiwiki.org with no results. The configuration I'm using is the following.

Host : libad1.library.nova.edu Port : 389 Scope: Sub Base DN: dc=library,dc=nova,dc=edu Ldap User DN: OU=Systems Users User Attrib: samAccountName User OC: user Group dn blank Group attrib blank Group OC blank Member Attrib blank Member is dn n LDAP Admin User: pipopo

pipopo is the domain administrator Please let me know what to correct...

thanks,

christian




I had success with the configuration below. None of the above worked as-is for me, and I had to change some code to get this working properly.

In lib/LDAP.php I changed line 189 from:

if ((@ldap_bind($this->conn_id)) == false) {
to
if ((@ldap_bind($this->conn_id,"user@domain.tld","password")) == false) {

Then I used the following values for "Login" in Admin panel:

Create user if not in Tiki? checked Create user if not in Auth? unchecked Just use Tiki auth for admin? checked LDAP URL: blank LDAP Host: my.domain.controller.com LDAP Port: 389 LDAP Scope: sub LDAP Base DN: DC=domain, DC=tld LDAP User DN: CN=Users (this is for default AD users container) LDAP User Attribute: sAMAccountName LDAP User OC: * LDAP Group DN: blank LDAP Group Attribute: blank LDAP Group OC: blank LDAP Member Attribute: LDAP Member Is DN: n LDAP Admin User: blank LDAP Admin Pwd: blank

YMMV. Hope this helps someone.




Make sure you use LDAPS or the passwords will be sent in clear over the network, this is how LDAP works. Alternatively you can start TLS with LDAP, but it requires you to edit lib/userslib.php and add

options"start_tls"=true;

in the LDAP portion of this library.

A future version of tikiwiki will include the option start_tls



Find by Page Name

Exact match

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki documentation and should correspond to development keywords (bug reports and feature requests):