Forums

Home » Alloy UI » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Muhamad Yaqin Mhd Nor
user migration from drupal into liferay.
April 22, 2012 11:36 PM
Answer

Muhamad Yaqin Mhd Nor

Rank: New Member

Posts: 6

Join Date: April 22, 2012

Recent Posts

Hi techie.

I have user inside my drupal database, now i want to migrate all this user into liferay. But as i can confirm here the password encryption is different. My objective is i want to migrate entire user and login with liferay as usual without changing their password and username. What is the best practise ? and the best approach ?.
Oliver Bayer
RE: user migration from drupal into liferay.
April 23, 2012 1:18 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Muhamad,

if the users are stored directly in the drupal db and not in e.g. LDAP/ AD I would sugguest writing an "admin-portlet" which uses liferay-services (use methods of the UserLocalServiceUtil class) to create the users. If the password encryption doesn't match I would create a default password for all of them and then check that they have to change their password at first login (so they can then use their drupal password).

HTH Oli
Muhamad Yaqin Mhd Nor
RE: user migration from drupal into liferay.
April 23, 2012 8:09 PM
Answer

Muhamad Yaqin Mhd Nor

Rank: New Member

Posts: 6

Join Date: April 22, 2012

Recent Posts

Oliver Bayer:
Hi Muhamad,

if the users are stored directly in the drupal db and not in e.g. LDAP/ AD I would sugguest writing an "admin-portlet" which uses liferay-services (use methods of the UserLocalServiceUtil class) to create the users. If the password encryption doesn't match I would create a default password for all of them and then check that they have to change their password at first login (so they can then use their drupal password).

HTH Oli


Hi Oliver.

Yes the user are stored directly into drupal db. Referring to your suggestion, what do you mean by writing an "admin portlet" can you explain more. Base on my understanding from what point did you give, i should create an "admin-portlet" and i have to create a bunch of user mirroring with drupal db and set a default password. So by the time their 1st login into liferay they have to change their password. Ok i will try.

But another question.
As we obviously clear, table "user in drupal and table "user" in liferay aren't same. Login id in liferay = email. login if in drupal = username. If i do the migration i still dont think it could be the best approach. Because there are a lot of column in liferay will become (null). Attached is a comparison db between drupal and liferay.
btw thank again oliver.

Oliver Bayer
RE: user migration from drupal into liferay.
April 24, 2012 1:37 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Mohamad,

I know that my answer was a shortcut of a more complex task but I will try to clearify it a bit more emoticon.

More details:
1. Setup a development environment using the Liferay SDK.
2. There are two ways how you can create a portlet: creating a hot deployable portlet or include it in an ext-plugin. I think you don't have to use an ext-plugin to achieve this so use a "standard" portlet. The Liferay IDE helps you to create a new one.
3. The portlet should only contain one button e.g. "migrate drupal users".
4. The backend logic is the biggest block:
- connect to the drupal db
- select all users
- re-create the users in liferay using the api:
User newUser = UserLocalServiceUtil.addUser(......);
You can use a user class as parameter or you can give all parameters to this method (take a look at this class).
- Now set the password reset to be required:
UserLocalServiceUtil.updatePasswordReset(newUser.getUserId(), true);

You can change the login field used by liferay via portal-ext.properties from email to screenName. I don't think it's a problem if some fields are empty or null in the liferay user_ table - you should just migrate the needed ones like e.g. email, first name, last name, screen name, password. The other fields aren't required (afaik).

Greets Oli
Muhamad Yaqin Mhd Nor
RE: user migration from drupal into liferay.
April 26, 2012 3:17 AM
Answer

Muhamad Yaqin Mhd Nor

Rank: New Member

Posts: 6

Join Date: April 22, 2012

Recent Posts

Oliver Bayer:
Hi Mohamad,

I know that my answer was a shortcut of a more complex task but I will try to clearify it a bit more emoticon.

More details:
1. Setup a development environment using the Liferay SDK.
2. There are two ways how you can create a portlet: creating a hot deployable portlet or include it in an ext-plugin. I think you don't have to use an ext-plugin to achieve this so use a "standard" portlet. The Liferay IDE helps you to create a new one.
3. The portlet should only contain one button e.g. "migrate drupal users".
4. The backend logic is the biggest block:
- connect to the drupal db
- select all users
- re-create the users in liferay using the api:

User newUser = UserLocalServiceUtil.addUser(......);
You can use a user class as parameter or you can give all parameters to this method (take a look at this class).
- Now set the password reset to be required:
UserLocalServiceUtil.updatePasswordReset(newUser.getUserId(), true);

You can change the login field used by liferay via portal-ext.properties from email to screenName. I don't think it's a problem if some fields are empty or null in the liferay user_ table - you should just migrate the needed ones like e.g. email, first name, last name, screen name, password. The other fields aren't required (afaik).

Greets Oli


Great explanation Oli. ok so far if i use this script. what do you think ? this is about 9 thousand users. emoticon i need to manage it well.

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.commons.codec.binary.Base64;

public class Test {

/**
* @param args
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
String input = "password";
MessageDigest digest = null;

digest = MessageDigest.getInstance("MD5");
digest.update(input.getBytes("UTF-8"));

byte[] rawData = digest.digest();
byte[] encoded = Base64.encodeBase64(rawData);
String retValue = new String(encoded);
System.out.println(retValue);
}
}
Audrey Moore
RE: user migration from drupal into liferay.
May 1, 2012 3:56 AM
Answer

Audrey Moore

Rank: New Member

Posts: 3

Join Date: May 1, 2012

Recent Posts

Thanks Oli, great help. I have transferred all my users. Although not that much with Muhammad, I just only have around 80 emoticon so its kinda easy.
Oliver Bayer
RE: user migration from drupal into liferay.
May 2, 2012 1:51 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Audrey,

I'm glad to hear that it worked for you this way, thanks for the feedback emoticon.

@Muhammad:
I don't think that you need to encrypt the passwords on your own. In the UserLocalServiceImpl.addUserWithWorkflow the clear-text password which is a method parameter is encrypted using the PwdEncryptor class.

Greets Oli
Muhamad Yaqin Mhd Nor
RE: user migration from drupal into liferay.
May 3, 2012 5:18 AM
Answer

Muhamad Yaqin Mhd Nor

Rank: New Member

Posts: 6

Join Date: April 22, 2012

Recent Posts

"You can change the login field used by liferay via portal-ext.properties from email to screenName. I don't think it's a problem if some fields are empty or null in the liferay user_ table - you should just migrate the needed ones like e.g. email, first name, last name, screen name, password. The other fields aren't required (afaik)."

Hi oli, you are back emoticon. i am waiting your reply. Thank you so much. I just wondering with my portal-ext.properties as you said i can change but why inside my portal-ext.properties i just have jdbc ?

#
# MySQL
#
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=abc123

did you mean i have to change in portal.properties ?

thank oli.
Muhamad Yaqin Mhd Nor
RE: user migration from drupal into liferay.
May 3, 2012 5:21 AM
Answer

Muhamad Yaqin Mhd Nor

Rank: New Member

Posts: 6

Join Date: April 22, 2012

Recent Posts

Audrey Moore:
Thanks Oli, great help. I have transferred all my users. Although not that much with Muhammad, I just only have around 80 emoticon so its kinda easy.


great audrey. can you teach me ? do you have gtalk ? please.. emoticon
Hitoshi Ozawa
RE: user migration from drupal into liferay.
May 3, 2012 6:12 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Set the following property to change login to use screen name instead of email address

#
# The portal can authenticate users based on their email address, screen
# name, or user id.
#
#company.security.auth.type=emailAddress
company.security.auth.type=screenName
#company.security.auth.type=userId

Following page contains a sample to use web service to add user information in csv file to liferay. Just customize it to use jdbc instead of csv file.
The sample is written for liferay 6.0.5, you'll need to make minor adjustment to liferay api parameters to work with 6.1.0. build should give error messages
on what needs to be changed.
Oliver Bayer
RE: user migration from drupal into liferay.
May 3, 2012 7:38 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Muhammad,

use the key Hitoshi mentioned. FYI the portal-ext.properties overrides the settings in portal.properties therefore you should place all of your changes into the portal-ext.properties.

@Hitoshi:
You took my answer right out of my mouth - you're simply toooo fast in answering emoticon. Congrats for winning the Liferay Award - you deserve it.

Greets Oli
Hitoshi Ozawa
RE: user migration from drupal into liferay.
May 3, 2012 8:45 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Sorry that this post isn't actually related to the topic of the thread.

Congrats for winning the Liferay Award - you deserve it.


Thank you very much. At first, my company wanted me to donate my I18N and L10N Japanese modifications and my portlets to Liferay.com so we won't have to maintain them, but Brian didn't want them. Now, it seems Liferay.com has some interest in them, but my company doesn't want me making them public. Such is life. :-)

At first, the company I work for didn't know I could program and provide support because I've mostly been doing contracting, administrative works, and consulting. They, also, didn't think I knew this much English too. lol
Muhamad Yaqin Mhd Nor
RE: user migration from drupal into liferay.
May 4, 2012 12:47 AM
Answer

Muhamad Yaqin Mhd Nor

Rank: New Member

Posts: 6

Join Date: April 22, 2012

Recent Posts

Oliver Bayer:
Hi Muhammad,

use the key Hitoshi mentioned. FYI the portal-ext.properties overrides the settings in portal.properties therefore you should place all of your changes into the portal-ext.properties.

@Hitoshi:
You took my answer right out of my mouth - you're simply toooo fast in answering emoticon. Congrats for winning the Liferay Award - you deserve it.

Greets Oli


@oli. aha ok now i understand diff between portal ext and portal properties.

@hitoshi wow congrats hitoshi : Joudeki dayo. by the way thank you for your advise.