Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import users in liferay with some exando fields

 
Tibi Kiss
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today I would like to solve the migration of my old non-liferay user database into Liferay 6.1.
I have all the required fields, plus I know that I need 3 more expando fields.

I have seen codes which can programatically create users, but I don't know how to add those 3 expando fields too when the users are just created.
 
Jonas X. Yuan
author
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tibi,

Do you use LDAP server integration?

Yes, the custom fields (expando) could be used in the LDAP user info mapping.

Thanks

Jonas Yuan
 
Tibi Kiss
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately I am not using LDAP. I have here a simple database table based authentication, once implemented with spring security.

Let's describe my integration between my old stuffs and the liferay.
Initially I had a database where there is a User table and some foreign keys refers to that User table.
I didn't merged my old tables into liferay database, instead I kept as it is. But I created the most simple integration of the users, such as in my old (code to be migrated in portal env) where the authenticated user is used to lookup the user table, there I introduced a mapping, by first asking from the liferay's themeDisplay the logged in User (if any) and then with that id, I am looking that I have already cloned the user data or not, into the old users table. If not, then I am creating that record, reading also the 3 expando fields form liferay which is necessary to match all the field's requirement in my old users table.

I'm not convinced about this approach, maybe later on I'll introduce a hook, by implementing the user service from liferay.
(My current first aproach also handles user details changes also, but it's a bit too late when it is executed. It's fine for the logged in user itself, but if some administrative tasks uses the old users table, theoretically it may get caught in an inconsistent state, not reflecting the latest changes of the user once executed in liferay. In practice, this is happening if the user immediately logged out after changing its details.)
 
Amro Ali
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at this blog for details on using expando. I know it's written in velocity, but velocity leverages java objects and methods.

If you require more detailed examples in java just reply again to the post and I'll post some.
 
Tibi Kiss
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amro Ali wrote:Take a look at this blog for details on using expando. I know it's written in velocity, but velocity leverages java objects and methods.

If you require more detailed examples in java just reply again to the post and I'll post some.


Thanks for the link. It will be the today's task :-)
 
Tibi Kiss
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact user import is extremly easy.



I also get into problems with password migration. Looks like my old passwords are md5 with salted hash. Unfortunately Liferay does not support this kind of digest.
If I could hook (or with ext env) the com.liferay.portal.security.pwd.PwdEncryptor, or com.liferay.portal.security.pwd.PwdAuthenticator it would be one way to migrate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic