Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Ram A
Avoid the user 'userA' while importing the users from ldap using Liferay.
29 gennaio 2013 3.00
Risposta

Ram A

Punteggio: Junior Member

Messaggi: 76

Data di Iscrizione: 16 gennaio 2013

Messaggi recenti

Hi,

I am new to Liferay.
Liferay imports the users from ldap at frequent intervals and when user tries to login to the application first time.

Supppose i have a user 'userA' in ldap and while importing from ldap i don't need to import that user.
Liferay has to avoid the importing of that user .
my portal-ext.properties has the following configuration.

ldap.users.dn=OU=Users,OU=OU_HE,DC=gen,DC=domain,DC=com
ldap.user.mappings=screenName=sAMAccountName\npassword=userPassword\nemailAddress=userprincipalname\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=memberOf
ldap.import.user.search.filter=(|(&(objectClass=person)(objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gen,DC=domain,DC=com)(displayName=*)(givenName=*)(sAMAccountName=*)(userprincipalname=*)(sn=*)(!(sAMAccountName=* *))(!(sAMAccountName=*_*)))(&(objectClass=person)(CN=*liferay*)(!(sAMAccountName=* *))(!(sAMAccountName=*_*))))

ldap.import.group.search.filter=(&(objectClass=group)(CN=*liferayportal*))
ldap.import.enabled=true
ldap.import.interval=20
ldap.import.on.startup=true

Please help me how can we avoid the importing of user from ldap when he tries to login to the liferay application.
Please anybody help me how to avoid that perticular user having screenname 'screenA' while importing from ldap.

Thanks in advance
Ram A
\
Siby Mathew
RE: Avoid the user 'userA' while importing the users from ldap using Lifera
29 gennaio 2013 6.27
Risposta

Siby Mathew

Punteggio: Expert

Messaggi: 267

Data di Iscrizione: 4 marzo 2011

Messaggi recenti

Hi Ram,
If you only specify the LDAP config and disable the import properties, then liferay will try to import the user only when he logs in.
You may override UserLocalServiceImpl.authenticateByScreenName() using a hook.
At that point you have the screenname entered by the user.
You can check if its screenA, then call super.authenticateForBasic(), otherwise call super.authenticateByScreenName()

Hope this helps

Thanks,
Siby Mathew
Ram A
RE: Avoid the user 'userA' while importing the users from ldap using Lifera
5 febbraio 2013 7.47
Risposta

Ram A

Punteggio: Junior Member

Messaggi: 76

Data di Iscrizione: 16 gennaio 2013

Messaggi recenti

Siby Mathew:
Hi Ram,
If you only specify the LDAP config and disable the import properties, then liferay will try to import the user only when he logs in.
You may override UserLocalServiceImpl.authenticateByScreenName() using a hook.
At that point you have the screenname entered by the user.
You can check if its screenA, then call super.authenticateForBasic(), otherwise call super.authenticateByScreenName()

Hope this helps

Thanks,
Siby Mathew



Thanks Siby for the help.
My scenario is as follows:
I am using liferay 6.0.6 and i am importing the users from ldap at frequent intervals and on server startup.
i am doing the user authentication by screen name not email Address.

When it is trying to import all users from ldap,if user existed in 'User_ ' table it is updating that record.
If user(say 'X' imported from ldap) does not exists it is trying to add that user in DB.
if any other user in liferay table 'User_' has the same company id and emailAddress of user 'X' ,it is throwing the below error while adding 'X' in DB.

13:39:57,951 ERROR [JDBCExceptionReporter:234] Cannot insert duplicate key row in object 'dbo.User_' with unique index 'IX_615E9F7A'.
13:39:57,953 ERROR [PortalLDAPImporterImpl:507] Unable to import user CN=Mikhail Popov,OU=Users,OU=OU_HMT: null:null:{samaccountname=sAMAccountName: erumpopo}
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:190)
at com.liferay.portal.service.persistence.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:551)
at com.liferay.portal.service.persistence.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:1)
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:254)
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:274)
at com.liferay.portal.service.impl.MyUserLocalServiceImpl.addUser(MyUserLocalServiceImpl.java:422)


how can we filter the users while importing such that if the importing user has the same company id and emailAddress of the existing user in DB,we can exclude the importing of user.
Is it possible?

Please help me .


Thanks in advance
Ram A