Foren

[Resolved]Unable to import user in Liferay [portalLDAPImporterImpl]

Ram A, geändert vor 11 Jahren.

[Resolved]Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
Hi ,
i am new to liferay.
I am using liferay 6.0.6 .

I am getting the below while importing the user and adding/updating the users in dbo.User_ table.

13:35:21,559 ERROR [JDBCExceptionReporter:234] Cannot insert duplicate key row in object 'dbo.User_' with unique index 'IX_615E9F7A'.
13:35:21,560 ERROR [PortalLDAPImporterImpl:507] Unable to import user CN=Moritz Hansen,OU=Fixe,OU=Users_PCRefresh,OU=OU_SH: null:null:{samaccountname=sAMAccountName: ebohfmn}
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)
at sun.reflect.GeneratedMethodAccessor436.invoke(Unknown Source)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy81.addUser(Unknown Source)
at com.liferay.portal.service.UserLocalServiceUtil.addUser(UserLocalServiceUtil.java:291)
at com.liferay.portal.security.ldap.MyPortalLDAPImporterImpl.addUser(MyPortalLDAPImporterImpl.java:336)
at com.liferay.portal.security.ldap.MyPortalLDAPImporterImpl.importUser(MyPortalLDAPImporterImpl.java:674)
at com.liferay.portal.security.ldap.MyPortalLDAPImporterImpl.importFromLDAPByUser(MyPortalLDAPImporterImpl.java:497)
at com.liferay.portal.security.ldap.MyPortalLDAPImporterImpl.importFromLDAP(MyPortalLDAPImporterImpl.java:179)
at com.liferay.portal.security.ldap.PortalLDAPImporterImpl.importFromLDAP(PortalLDAPImporterImpl.java:41)
at com.liferay.portal.security.ldap.MyPortalLDAPImporterImpl.importFromLDAP(MyPortalLDAPImporterImpl.java:85)
at com.liferay.portal.security.ldap.PortalLDAPImporterUtil.importFromLDAP(PortalLDAPImporterUtil.java:30)

at com.liferay.portlet.admin.messaging.LDAPImportMessageListener.doReceive(LDAPImportMessageListener.java:27)
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:25)
at sun.reflect.GeneratedMethodAccessor506.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

my portal-ext.properties file has below settings for ldap:

ldap.auth.search.filter=(&(objectCategory=person)(sAMAccountName=@screen_name@))
ldap.users.dn=OU=Users,OU=OU_HE,DC=com,DC=sample,DC=domain,DC=com
ldap.user.mappings=screenName=sAMAccountName\npassword=userPassword\nemailAddress=userprincipalname\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=memberOf

ldap.import.enabled=true
ldap.import.interval=30
ldap.import.on.startup=true

Have anyone faced this issue earlier?

Please help me to solve this issue.

Thanks in advance
Ram A
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Ram A:
13:35:21,559 ERROR [JDBCExceptionReporter:234] Cannot insert duplicate key row in object 'dbo.User_' with unique index 'IX_615E9F7A'.
13:35:21,560 ERROR [PortalLDAPImporterImpl:507] Unable to import user CN=Moritz Hansen,OU=Fixe,OU=Users_PCRefresh,OU=OU_SH: null:null:{samaccountname=sAMAccountName: ebohfmn}
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update


Seems clear to me, you have a duplicate user. Probably one that you created manually that conflicts with the one trying to be imported from LDAP...
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
David H Nebinger:
Ram A:
13:35:21,559 ERROR [JDBCExceptionReporter:234] Cannot insert duplicate key row in object 'dbo.User_' with unique index 'IX_615E9F7A'.
13:35:21,560 ERROR [PortalLDAPImporterImpl:507] Unable to import user CN=Moritz Hansen,OU=Fixe,OU=Users_PCRefresh,OU=OU_SH: null:null:{samaccountname=sAMAccountName: ebohfmn}
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update


Seems clear to me, you have a duplicate user. Probably one that you created manually that conflicts with the one trying to be imported from LDAP...


Hi David,

Thanks for the reply.
what i understood from your comment is as follows.
suppose i created the user 'A' through control panel manually .it is conflicting with the one that is being imported from LDAP to liferay.

FYI: User "Moritz Hansen" doesn't exist in the table USER_ table.

But i have doubt that when i have created the user ,the emaiaddress and user id of that user should be different with the one that is being imported right?

But first it should import the user and then it will add the user to DB right.
Does it check the User_ table before importing the user?.

In the line "CN=Moritz Hansen,OU=Fixe,OU=Users_PCRefresh,OU=OU_SH: nul:null",it is showing null:null.
i am not able to understand what is this null.

Can you please help me .


Thanks in advance
Ram A
Siby Mathew, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
Hi Ram,
First of all keep the liferay source code with you. Then you can take a look directly in the code.
If you see PortalLDAPImporterImpl, you can see it is :
_log.error("Unable to import user " + searchResult, e);


Hence it is calling searchResult.toString().

If you check the overridden toString() method inside SearchResult.java, it is :
return (new StringBuilder()).append(super.toString()).append(":").append(getAttributes()).toString();


So the NULL things are nothing but the specified LDAP attributes.

Thanks,
Siby
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
Siby Mathew:
Hi Ram,
First of all keep the liferay source code with you. Then you can take a look directly in the code.
If you see PortalLDAPImporterImpl, you can see it is :
_log.error("Unable to import user " + searchResult, e);


Hence it is calling searchResult.toString().

If you check the overridden toString() method inside SearchResult.java, it is :
return (new StringBuilder()).append(super.toString()).append(":").append(getAttributes()).toString();


So the NULL things are nothing but the specified LDAP attributes.

Thanks,
Siby


Thanks Suby for the reply.
what i got from this is some attributes for the user are null and i am getting the error(unable to import the user) for those users while importing and
because of this it is giving the error while adding that user in User_ table.

Am i correct ?
i am getting this error not only for one user.This error is coming for so many users.

Please help me to fix this issue.

Thanks in advance
Ram A
Siby Mathew, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
Hi,
This may not be the problem with the null values itself.
The error shows :
"Cannot insert duplicate key row"

So it means the currently processed user is having some duplicate values with the user already present inside DB.
Check if you have any common values.

Thanks,
Siby
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
Hi Siby,

Thanks for quick reply.

what i found is User_ table has unique index(IX_6159F7A) on columns 'emailAddress' and 'companyId'.
Supoose the user which is being impoted to Liferay DB has the same emailaddress as the email Address of existing user 'XXXX' ,it may causes this error.

i am thinking this duplicate emailAddress causes the problem.

1.Suppose this index causes the problem how will it be resolved?

2. Suppose that is the duplicate emailaddress can this be edited before adding it to the DB using portal-ext.properties file (if user has emailaddress null then we can generate it by using auto.suffix property)

3.i would like to know how the impoerting of users is happening(filtering while searching) from ldap.
i mean i have two properties in portal-ext.properties.
a.ldap.user.dn=OU=Users,OU=OU_HE,DC=gen,DC=sample,DC=domain,DC=com
b.ldap.import.user.search.filter=(|(&(objectClass=person)(objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=sample,DC=domain,DC=com)(displayName=*)(givenName=*)(sAMAccountName=*)(userprincipalname=*)(sn=*)(!(sAMAccountName=* *))(!(sAMAccountName=*_*)))(&(objectClass=person)(CN=*liferay*)(!(sAMAccountName=* *))(!(sAMAccountName=*_*))))

How filtering while importing users will be done ?based on a or b?

Can you please help regarding these.


Thanks in advance.
Ram A
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Ram A:
Supoose the user which is being impoted to Liferay DB has the same emailaddress as the email Address of existing user 'XXXX' ,it may causes this error.


Email address must be unique per company. You cannot import users that have duplicate email addresses.
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
David H Nebinger:
Ram A:
Supoose the user which is being impoted to Liferay DB has the same emailaddress as the email Address of existing user 'XXXX' ,it may causes this error.


Email address must be unique per company. You cannot import users that have duplicate email addresses.



Thanks David for reply.

Suppose liferay doesnot import a user having duplicate emailAddress of the other existing user,it should not try to add it in Liferay DB right.

what i mean is user 'A '(existed in User_ table) has company id '10151' and emailAddress 'sample@liferay.com'.
Now liferay imports the other users 'user X'(doesn't exist in User_) has the same company id '10151' and same emailAddress as that of user 'A'.
As 'user X' does not exist in the table liferay will try to add this user in 'User_' table.

FYI: we are authenticating the user based on Screen name not emailAddress.

Because of unique index on 'companyId' and 'emailAddress' in the table 'User_ ' it is giving the below error.

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_HMR: 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)
Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:30)
at com.liferay.portal.dao.orm.hibernate.SessionImpl.flush(SessionImpl.java:118)
at com.liferay.portal.kernel.dao.orm.ClassLoaderSession.flush(ClassLoaderSession.java:176)
at com.liferay.portal.service.persistence.BatchSessionImpl.update(BatchSessionImpl.java:95)
at com.liferay.portal.service.persistence.BatchSessionUtil.update(BatchSessionUtil.java:49)
at com.liferay.portal.service.persistence.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:546)
... 41 more

I think this is what happening .

Please correct me if i am wrong.
Please help me to resolve this issue.

Thanks in advance
Ram A
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Ram A:
Suppose liferay doesnot import a user having duplicate emailAddress of the other existing user,it should not try to add it in Liferay DB right.


Liferay does not keep track of previous import failures. Liferay is trying to synchronize it's user database with what is in ldap. It will continue to try and import the record.

You can control this by adding an attribute to LDAP and your Liferay LDAP filter so duplicates would be excluded.
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
David H Nebinger:
Ram A:
Suppose liferay doesnot import a user having duplicate emailAddress of the other existing user,it should not try to add it in Liferay DB right.


Liferay does not keep track of previous import failures. Liferay is trying to synchronize it's user database with what is in ldap. It will continue to try and import the record.

You can control this by adding an attribute to LDAP and your Liferay LDAP filter so duplicates would be excluded.



Thanks David for quick reply.
what i understood from this is if there exists user('A') in User_ table with the emailAddress of the user(say 'X')who is being imported to Liferay DB,it won't import that user right.

But here it is trying to add the user('X') in User_ table and it is giving the ConstraintViolation exception .May i know why this happening.

How can we filter while importing the users so that if user A existed in DB with emailaddress and companyid of the user 'X' who is being imported ,so importing of user 'X' will be excluded.

My Portal-ext.properties config is:
ldap.import.user.search.filter=(|(&(objectClass=person)(objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=sample,DC=domain,DC=com)(displayName=*)(givenName=*)(sAMAccountName=*)(userprincipalname=*)(sn=*)(!(sAMAccountName=* *))(!(sAMAccountName=*_*)))(&(objectClass=person)(CN=*liferay*)(!(sAMAccountName=* *))(!(sAMAccountName=*_*))))

ldap.user.mappings=screenName=sAMAccountName\npassword=userPassword\nemailAddress=userprincipalname\nfirstName=givenName\nlastName=sn\njobTitle=title\ngroup=memberOf

ldap.users.dn=OU=Users,OU=OU_LT,DC=test,DC=sample,DC=domain,DC=com

one small doubt is :
If we do not mention any one of the properties ldap.import.method=group and ldap.import.method=user,how import will be happened by default?


Please help me .

Thanks in advance
Ram A
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
Hi ,

i am getting the below errors while importing the users from ldap for some users.

[PortalLDAPImporterImpl:507] Unable to import user CN=Martyn Stevens,OU=Users,OU=Users,OU=OU_HUM: null:null:{samaccountname=sAMAccountName: 112740}
com.liferay.portal.GroupFriendlyURLException
at com.liferay.portal.service.impl.GroupLocalServiceImpl.validateFriendlyURL(GroupLocalServiceImpl.java:1381)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.addGroup(GroupLocalServiceImpl.java:160)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.addGroup(GroupLocalServiceImpl.java:233)
at sun.reflect.GeneratedMethodAccessor1184.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)


Please help me to fix this issue.


Thanks in advance
Ram A
Siby Mathew, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Expert Beiträge: 268 Beitrittsdatum: 04.03.11 Neueste Beiträge
Hi Ram,
As the error denotes, the problem is with the generated groups' friendlyurl (Validation failure).
This might be formed from incoming data imported from LDAP.
If you take a look in the liferay source code , GroupLocalServiceImpl - Line no: 1381, you can figure out the problem easily.

Thanks,
Siby
Ram A, geändert vor 11 Jahren.

RE: Unable to import user in Liferay [portalLDAPImporterImpl]

Junior Member Beiträge: 76 Beitrittsdatum: 16.01.13 Neueste Beiträge
Thanks Siby for quick reply.

The problem is with the usernames and usergroups.

I added the below property in portal-ext.properties file.
ldap.import.method=group

Now it is importing the users based on usergroups and i am not getting any error.

I think this fixed the issue.

Thanks all for your help in fixig this issue.

Regards,
Ram A