This page seeks to explain LDAP's use in Liferay.
<!--
ldap.base.provider.url=ldap://192.168.94.128:19389
ldap.base.dn=dc=localdomain
ldap.security.principal=cn=dirman
ldap.security.credentials=password
- Open the certificates mmc snapin.
- Export the Root Certificate Authority certificate located at: Certificates (Local Computer) mmc snapin>Trusted Root Certification Authorities>MyRootCACertificateName
(right click this certificate>all tasks>export>select DER encoded binary X.509 .CER)
- Copy the exported .cer file to the server where your JDK lives under which liferay is ulitmately running.
- Import the certificate into the cacerts keystore (you may be able to create your own keystore but this example just imports it into the default
cacerts keystore provided by the Sun JDK 1.5.x). The import is handled by a command like the following.
- In liferay admin console>users>authentication>ldap specify a URL like the following (note ldaps:// and port 636 instead of ldap:// and 389 for
non-ssl connections).
- Save the change. Test it out.
The LDAP class that handles the connection and search of LDAP is LDAPAuth. LDAPUtil is used to help grab attributes.
In portal.properties, LDAP is part of the authentication pipeline:
auth.pipeline.pre=com.liferay.portal.security.auth.LDAPAuth
When using By Screen Name as user authentication method, the following LDAP filter can be used to match the entered login name:
(cn=@screen_name@)Where screen_name is replaced by the login name the user entered. (Note: This is known to work with Liferay 4.3, but I couldn't find any official guarantee for it)
ldap.auth.enabled=true
ldap.auth.required=true
ldap.users.dn=ou=People,dc=localdomain
ldap.groups.dn=ou=Groups,dc=localdomain
ldap.user.mappings=screenName=cn\npassword=userPassword\nemailAddress=mail\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=groupMembership
ldap.user.impl=com.liferay.portal.security.ldap.LDAPUser
ldap.group.mappings=groupName=cn\ndescription=description\nuser=uniqueMember
ldap.import.user.search.filter=(objectClass=inetOrgPerson)
ldap.import.group.search.filter=(objectClass=groupOfUniqueNames)
ldap.auth.search.filter=(mail=@email_address@)
Your company may want to have users login using some value other than their email address. For example, if you have your LPAD configured and want your users to login using their another value, say their "userid" (see picture below)
![]() |
For the configuration above, you would use the following settings:
![]() |
ldap.auth.enabled=true
ldap.auth.required=true
company.security.auth.type=screenName
ldap.auth.search.filter=(uid=@screen_name@)
ldap.user.mappings=screenName=uid\npassword=userPassword\nemailAddress=mail\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=groupMembership
ldap.user.default.object.classes=top,person,inetOrgPerson,organizationalPerson,account
This maps Liferay's "screenName" value to LDAP's "uid" value.
For example, lets say we have a user in LDAP with the userid of "112143134". Because of the properties (see above), when this user tries to log in, Liferay will try to find a user with a screenname of "112143134" using the specified search filter "(uid=@screen_name@)". When Liferay finds this user, it will import this user into Liferay according to the specified user mappings.
Liferay Portal can be configured to periodically check an LDAP server and add any new user accounts to the portal database. The importer is able to:
This feature is highly configurable. It is possible to define an LDAP search filter to limit which user accounts will be imported and to define the mapping of LDAP attribute names to portal profile names.
ldap.import.enabled=true
ldap.import.on.startup=true
ldap.import.interval=10
ldap.import.method=user (or group)
Liferay can import LDAP users and LDAP groups at 3 different times
For those interested in specific details, the implementation of this functionality is done by the classes LDAPImportJob and LDAPImportUtil.
(see below for explanation of export settings)
ldap.import.enabled=true
ldap.import.interval=10
ldap.import.on.startup=true
ldap.import.method=group
ldap.export.enabled=false
ldap.users.dn=ou=People,dc=localdomain
ldap.groups.dn=ou=Groups,dc=localdomain
ldap.user.default.object.classes=top,person,inetOrgPerson,organizationalPerson
Password Policies have been introduced to Liferay Portal beginning in version 4.3. The default setting is for the portal to use a local password policy, but the portal can also be configured to use LDAP password policies.
![]() |
By default, a local "Default Password Policy" is created for you (as seen in the Enterprise Admin Portlet).
To configure the Portal to use LDAP's password policy, go to
![]() |
If that has been done correctly, when you try and view the Password Policy, you will get a message saying that you are not using a local password policy
![]() |
#
# Set this to true to use the LDAP's password policy instead of the portal
# password policy.
#
ldap.password.policy.enabled=false
#
# Set these values to be a portion of the error message returned by the
# appropriate directory server to allow the portal to recognize messages
# from the LDAP server. The default values will work for Fedora DS.
#
ldap.error.password.age=age
ldap.error.password.expired=expired
ldap.error.password.history=history
ldap.error.password.not.changeable=not allowed to change
ldap.error.password.syntax=syntax
ldap.error.password.trivial=trivial
ldap.error.user.lockout=retry limit
(add any questions you may have here)
##
## LDAP Import
##
ldap.import.enabled=false
ldap.import.on.startup=false
#
# Enter time in minutes. This is how often the importer will synchronize
# with LDAP. This property is portal wide. Company override will be ignored.
#
ldap.import.interval=10
ldap.import.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
ldap.import.base.provider.url=ldap://localhost:10389
ldap.import.base.dn=dc=example,dc=com
ldap.import.security.principal=uid=admin,ou=system
ldap.import.security.credentials=secret
ldap.import.search.filter=(objectClass=inetOrgPerson)
ldap.import.user.mappings=userId=cn\npassword=userPassword\nemailAddress=mail\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=groupMembership
ldap.import.group.mappings=groupName=cn\ndescription=description
##
## LDAP
##
#
# Set the values used to connect to a LDAP store.
#
ldap.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
ldap.base.provider.url=ldap://localhost:10389
ldap.base.dn=dc=example,dc=com
ldap.security.principal=uid=admin,ou=system
ldap.security.credentials=secret
#
# Settings for com.liferay.portal.security.auth.LDAPAuth can be configured
# from the Admin portlet. It provides out of the box support for Apache
# Directory Server, Microsoft Active Directory Server, Novell eDirectory,
# and OpenLDAP. The default settings are for Apache Directory Server.
#
# The LDAPAuth class must be specified in the property "auth.pipeline.pre"
# to be executed.
#
# Encryption is implemented by com.liferay.util.Encryptor.provider.class in
# system.properties.
#
ldap.auth.enabled=false
ldap.auth.required=false
#
# Set either bind or password-compare for the LDAP authentication method.
# Bind is preferred by most vendors so that you don't have to worry about
# encryption strategies.
#
ldap.auth.method=bind
#
# Active Directory stores information about the user account as a series of
# bit fields in the UserAccountControl attribute.
#
# If you want to prevent disabled accounts from logging into the portal you
# need to use a search filter similiar to the following:
# (&(objectclass=person)(userprincipalname=@email_address@)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))
#
# See the following links:
# [http://support.microsoft.com/kb/305144/]
# [http://support.microsoft.com/?kbid=269181]
#
ldap.auth.search.filter=(mail=@email_address@)
ldap.auth.password.encryption.algorithm=
ldap.auth.password.encryption.algorithm.types=MD5,SHA
#
# The following settings are used to map LDAP users to portal users.
#
# You can write your own class that extends
# com.liferay.portal.security.ldap.LDAPUser to customize the behavior for
# exporting portal users to the LDAP store.
#
ldap.users.dn=dc=example,dc=com
#ldap.users.dn=ou=users,dc=example,dc=com
ldap.user.mappings=screenName=cn\npassword=userPassword\nemailAddress=mail\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=groupMembership
ldap.user.impl=com.liferay.portal.security.ldap.LDAPUser
ldap.user.default.object.classes=top,person,inetOrgPerson,organizationalPerson
#
# The following settings are used to map LDAP groups to portal user groups.
#
ldap.groups.dn=ou=groups,dc=example,dc=com
ldap.group.mappings=groupName=cn\ndescription=description\nuser=uniqueMember
#
# Settings for importing users and groups from LDAP to the portal.
#
ldap.import.enabled=false
ldap.import.on.startup=false
ldap.import.interval=10
ldap.import.user.search.filter=(objectClass=inetOrgPerson)
ldap.import.group.search.filter=(objectClass=groupOfUniqueNames)
#
# Set either user or group for import method. If set to user, portal will
# import all users and the groups associated with those users. If set to
# group, the portal import all groups and the users associated those groups.
# This value should be set based on how your LDAP server stores group
# membership information.
#
ldap.import.method=user
#ldap.import.method=group
#
# Settings for exporting users from the portal to LDAP. This allows a user
# to modify his first name, last name, etc. in the portal and have that
# change get pushed to the LDAP server. This will only be active if the
# property "ldap.auth.enabled" is also set to true.
#
ldap.export.enabled=true
#
# Set this to true to use the LDAP's password policy instead of the portal
# password policy.
#
ldap.password.policy.enabled=false
#
# Set these values to be a portion of the error message returned by the
# appropriate directory server to allow the portal to recognize messages
# from the LDAP server. The default values will work for Fedora DS.
#
ldap.error.password.age=age
ldap.error.password.expired=expired
ldap.error.password.history=history
ldap.error.password.not.changeable=not allowed to change
ldap.error.password.syntax=syntax
ldap.error.password.trivial=trivial
ldap.error.user.lockout=retry limit
A very helpful tool in configuring LDAP would be to build something to the effect of a LDAP configuration wizard. This should display some basic information:
The best way to learn how to set up the Liferay LDAP integration is to check the available Lifecast at:
http://www.liferay.com/web/guest/documentation/4_2/installation_and_customization
(Direct link to the last version of the lifecast at the time of writting this: ldap .swf)
You can use tools like JXplorer to browse your LDAP server:
![]() |
Omniadmin users are allowed to log in even if the integration with LDAP is broken. This allows to use this administrator accounts to fix the problem. The default user created with liferay (test@liferay.com) is an example of an omniadmin users. Others can be configured in portal.properties (or portal-ext.properties) indicating a comma separated list of user ids:
4.2.X and before
omniadmin.users=liferay.com.1,liferay.com.1001
4.3.X
omniadmin.users=2,12345,98765
To make sure that LDAP integration is working with the version of the sources that you are using (if not using a stable version) you can run LDAP from the test package:
ant test-ldap
0 Attachments | Average (0 Votes) ![]() ![]() ![]() ![]() |