18 July, 2012

Custom LDAP attributes import

Hi Everyone,
If you want to import LDAP extra attributes in liferay , then you can achive this functionality two different ways :



1) If you are using LR 6.X then you can directly map your custom field attribute with LDAP by setting below property in portal-ext.properties file :

ldap.user.custom.mappings.0=phone,address

Here phone and address will be key of custom attributes which can be created from control panel.
So in this case you dont need to change any code.Please see below screen


For other LDAP import export you can check  http://www.liferaysolution.com/2012/07/ldap-import-export.html

2) if you want use existing liferay fields phone number and address then you may have to map these new fieldsin portal-ext.properties like :

ldap.user.mappings.0=uuid=uuid\nscreenName=cn\npassword=userPassword\nemailAddress=mail\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=groupMembership\naddres=addressLDAP\nphone=phoneLDAP

Here addressLDAP & phoneLDAP will be attributes of your LDAP schema and you can access this value in PortalLDAPImporterUtil class (importFromLDAP method).
So you may have to override this class and
Here you can get this value using : GetterUtil.getString(userMappings.getProperty("addres")).toLowerCase()

Rate Me:

4 Discussion:

Muhammed Shakir said...

Its a simple and nice blog Jignesh

Anonymous said...

hye.. I want to ask you something regarding liferay LDAP. I hope you don't mind spend your time on my question. :)

I already can import liferay user into open ldap. but cannot export open ldap user into liferay.
i already follow the tutorial. Some tutorial said we have to configure using control panel, but some totorial said not (because we have to configure using portal-ext.properties). I already follow both tutorial. but nothing happened.
It said that we have to change package package com.liferay.portal.security.ldap in class PortalLDAPImporterImpl , but I could not find this file.
So, I try to edit edit_ldap_server.jsp and test_ldap_user.jsp file. I add phone text field.Then, I call mobile attribute at LDAP server. The column for phone number exist and it display the value. but still, nothing happened when I edit the phone column in liferay. I create phone at liferay user using your tutorial.

hinags2002 said...

thanks man, this is what i was searching for since last 30minutes.

Nags

Hardik Pathak said...

Hi Jignesh, Thank you for this one.

Few questions,

1. You have mentioned ( and few other places on net I found )ldap.user.custom.mappings.0=, How you decide on 0 ? As I have already mapped my LDAP to my Liferay instance, and in database portalpreferences table it's ldap.user.mappings.12301. So in portal-ext.properties what should I use ?

2. I have already mapped LDAP and can login using LDAP username/password. But I want map UUID to a custom field of LDAP so that when user has forgotten username/password they can click reset it using UUID number. And that number is unique in LDAP. In worst case Can I assign that LDAP number to userId ?

3. I have added a custom field for USER object but I cant see the customfield into the liferay's user_ database table ? why ?

Thank you
Hardik