留言板

How to re-import users with new custom attribute

Ash J,修改在13 年前。

How to re-import users with new custom attribute

Junior Member 帖子: 83 加入日期: 11-3-22 最近的帖子
Hi,

I have already imported users from LDAP to Liferay. Now I need to add 'postalCode' attribute from LDAP to users in Liferay. I have added the custom attribute for 'Users' in Liferay and also added the new line in protal-ext.properties as below

ldap.user.custom.mappings=postalCode=postalCode

Now i need to import all the users from LDAP again with this attribute included.

Could someone please help me on how to do this. I have tried ticking the check box "Import on start-up", and restarted the server. But it does not import again.

Thanks in advance..

-ash
thumbnail
Shagul Khajamohideen,修改在13 年前。

RE: How to re-import users with new custom attribute

Liferay Master 帖子: 758 加入日期: 07-9-27 最近的帖子
Which version of Liferay are you using? Assuming 6.x, once the LDAP settings is saved from the control panel, the portal-ext.properties are not read for ldap settings. Also there is no UI to set the custom attributes ldap mapping from the control panel. A quick workaround is to delete the LDAP server from control panel and re-add the same. See if this works.

Best Regards,
Shagul
Ash J,修改在13 年前。

RE: How to re-import users with new custom attribute

Junior Member 帖子: 83 加入日期: 11-3-22 最近的帖子
Hi Shagul,

Thanks for your reply.

I'm using Liferay 6.0.6. So, did you mean to set all the LDAP configuration in portal-ext.properties file instead of adding them from control panel?

thanks,
ash
thumbnail
Shagul Khajamohideen,修改在13 年前。

RE: How to re-import users with new custom attribute

Liferay Master 帖子: 758 加入日期: 07-9-27 最近的帖子
You could add them from the control panel and enable/disable etc via the control panel as well. But if you need to change something and you cannot do that through the UI, you will need to force the properties to be read from the portal-ext.properties. The simple workaround is to delete the settings (ldap server) from control panel and re-add that. When you do that, these other properties in portal-ext.properties are read again as part of the LDAP settings.
Ash J,修改在13 年前。

RE: How to re-import users with new custom attribute

Junior Member 帖子: 83 加入日期: 11-3-22 最近的帖子
Hi Shagul,

Thanks for your comments.

I have managed to import custom attributes from LDAP with the workaround specified in the this post:

Workaround

Now, all my users were already imported. But the custom attributes are not present for those users, since they were imported before I apply the workaround. How can I re-import the users again? Deleting and re-creating the LDAP settings does re-import the users again.

Thanks,
ash.
thumbnail
Shagul Khajamohideen,修改在13 年前。

RE: How to re-import users with new custom attribute

Liferay Master 帖子: 758 加入日期: 07-9-27 最近的帖子
The workaround that I specified is to change the database entry without directly modifying it.

Are you saying some of your users have appropriate custom attributes and others don't? Based on what I remember seeing in PortalLDAPImporterImpl.java is, updateExpandoAttributes method is something that is called on all users.
Ash J,修改在13 年前。

RE: How to re-import users with new custom attribute

Junior Member 帖子: 83 加入日期: 11-3-22 最近的帖子
Here I'm bit confused.

So, are asking me to call this method from somewhere backend?? So, there is no way of refreshing all the user data from LDAP (or delete all users and import them again from LDAP) from Control Panel?

Thanks,
ash
thumbnail
Shagul Khajamohideen,修改在13 年前。

RE: How to re-import users with new custom attribute

Liferay Master 帖子: 758 加入日期: 07-9-27 最近的帖子
LDAP import may skip the users who are not modified. Based on the code that does the import, I see that the custom attribute updates are called irrespective whether the user is modified or not.

In order to trigger a complete import of all LDAP users, you could do one of the following.

1) Set the last modified for all users in the User_ table to something less than the current minimum value (or)
2) update the users in LDAP (may be using a script or something) so the modified date changes in the LDAP to current time.

Any time you make changes to the database directly, either you need to restart or clear database cache from the control panel ---> server administration.

Take a look at the code PortalLDAPImporterImpl.java for the version that you are on to see what the code does during import.
Ash J,修改在13 年前。

RE: How to re-import users with new custom attribute

Junior Member 帖子: 83 加入日期: 11-3-22 最近的帖子
Thanks Shagul for the valuable suggessions.

-ash
thumbnail
Shagul Khajamohideen,修改在13 年前。

RE: How to re-import users with new custom attribute

Liferay Master 帖子: 758 加入日期: 07-9-27 最近的帖子
The above workarounds are without any code change. If necessary you could always override the implementation of the LDAP Importer.