留言板

LDAP Mapping and Custom attributes

Nobilet Stéphane,修改在15 年前。

LDAP Mapping and Custom attributes

Regular Member 帖子: 100 加入日期: 08-2-28 最近的帖子
It's possible to configure a LDAP Mapping with the custom attributes ?

Thanks .
Tim Simon,修改在15 年前。

RE: LDAP Mapping and Custom attributes

New Member 帖子: 2 加入日期: 08-2-27 最近的帖子
i also have the same question.
Tony Lim,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 90 加入日期: 09-4-15 最近的帖子
same question, anyone have an answer for this?
Tony Lim,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 90 加入日期: 09-4-15 最近的帖子
Yes, under PortalLDAPUtil.java. you can add custom variables:

        String[] mappedUserAttributeIds = {
            userMappings.getProperty("screenName"),
            userMappings.getProperty("emailAddress"),
            userMappings.getProperty("fullName"),
            userMappings.getProperty("firstName"),
            userMappings.getProperty("middleName"),
            userMappings.getProperty("lastName"),
            userMappings.getProperty("jobTitle"),
            userMappings.getProperty("group"),
            "custom1"

        };


then you can call the variable like so:

String userId = LDAPUtil.getAttributeValue(attributes, "custom1");
        serviceContext.setUserId(Long.valueOf(userId));


Stéphane Nobilet:
It's possible to configure a LDAP Mapping with the custom attributes ?

Thanks .
Gloria Muñoz,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 43 加入日期: 08-11-4 最近的帖子
Hello,

I'm also trying to map ldap with custom attributes (phone number) but I cannot finish properly the users update/addition .

I mean, I've added an officePhone attribute, so I got:
String[] mappedUserAttributeIds = {
			userMappings.getProperty("screenName"),
			userMappings.getProperty("emailAddress"),
			[b]userMappings.getProperty("officePhone"),[/b]
			userMappings.getProperty("baseOffice"),
			userMappings.getProperty("fullName"),
			userMappings.getProperty("firstName"),
			userMappings.getProperty("middleName"),
			userMappings.getProperty("lastName"),
			userMappings.getProperty("jobTitle"),
			userMappings.getProperty("group")
		};


The conexion with ldap is working and I can read that new attribute with
String officePhone = LDAPUtil.getAttributeValue(attrs, userMappings.getProperty("officePhone"));


The problem appears when I try to save that attribute to the database. I've created a "custom attribute" through the GUI called "office-phone", so in importLDAPUser function (PortalLDAPUtil.java) I've added:
Map<string, serializable> expandoBridgeAttributes=new LinkedHashMap<string, serializable>();
		expandoBridgeAttributes.put("office-phone", officePhone);		
		serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes);</string,></string,>


Because, as far as I know, that is the way I have to specify values for new custom attributes..am I right?

The problem is that I got the following error when making the addition of the new "expando value":
[indent]ERROR [ExpandoBridgeImpl:255] com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
at com.liferay.portal.service.base.PrincipalBean.getPermissionChecker(PrincipalBean.java:77)
at com.liferay.portlet.expando.service.impl.ExpandoValueServiceImpl.addValue(ExpandoValueServiceImpl.java:51)
at sun.reflect.GeneratedMethodAccessor354.invoke(Unknown Source)...[/indent]

Does it means anything to you?

Any help would be appreciated.

Thanks!
Tony Lim,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 90 加入日期: 09-4-15 最近的帖子
I had the same problem. Here is a patch to fix it.

http://issues.liferay.com/browse/LPS-3070
Gloria Muñoz,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 43 加入日期: 08-11-4 最近的帖子
Perfect! That's it!

Thanks Tony
thumbnail
Nagendra Kumar Busam,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Liferay Master 帖子: 678 加入日期: 09-7-7 最近的帖子
Hi Gloria,

Can you let me know the exact steps needed to import other LDAP attributes

I want to import few more attributes (mobile,homePhone,facsimileTelephoneNumber,employeeNumber,homePostalAddress) from LDAP apart from default ones mentioned in LDAP settings.

Thanks in advance
thumbnail
Nagendra Kumar Busam,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Liferay Master 帖子: 678 加入日期: 09-7-7 最近的帖子
I tried with the steps mentioned in forum. BUT i was getting NullPointerException for method addValue of ExpandoValueLocalServiceUtil

Here is my code at UserLocalServiceImpl:

for (Map.Entry<String, Serializable> entry : serviceContext.getExpandoBridgeAttributes().entrySet()) {
if (!entry.getKey().isEmpty() && !entry.getValue().equals("") ) {
if (entry.getKey().equals("phone")) {
System.out.println("In phone");
ExpandoValueLocalServiceUtil.addValue("com.liferay.portal.model.Phone",
"phone",
"number_",
user.getPrimaryKey(),
entry.getValue());
} else {
System.out.println("postalCode - zip");
ExpandoValueLocalServiceUtil.addValue("com.liferay.portal.model.Address",
"address",
"zip",
user.getPrimaryKey(),
entry.getValue());
}

}

Any help ?
Gloria Muñoz,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 43 加入日期: 08-11-4 最近的帖子
Hi Nagendra,

I've been on holidays hope it's not too late..

I map the additional attributes in PortalLDAPUtil.java. I've only modified the UserLocalServiceImpl.java to replace the default calling to ExpandoBridge with ExpandoValueLocalServiceUtil.

So in UserLocalServiceImpl.java, around line 350 and 2285 I've replaced
ExpandoBridge expandoBridge = user.getExpandoBridge();

expandoBridge.setIndexEnabled(false);
expandoBridge.setAttributes(serviceContext);

with
if (  serviceContext.getExpandoBridgeAttributes() != null ) {
			for (Map.Entry<string, serializable> entry : serviceContext.getExpandoBridgeAttributes().entrySet()) {
				ExpandoValueLocalServiceUtil.addValue(User.class.getName(),
				                                      ExpandoTableConstants.DEFAULT_TABLE_NAME, 
				                                      entry.getKey(),
				                                      user.getUserId(),
				                                      entry.getValue());			
			}
}</string,>


and in PortalLDAPUtil.java you should modify getUserAttributes function to map your additional attributes like this(eg "mobile"):
String[] mappedUserAttributeIds = {
			userMappings.getProperty("screenName"),
			userMappings.getProperty("emailAddress"),
			userMappings.getProperty("fullName"),
			userMappings.getProperty("firstName"),
			userMappings.getProperty("middleName"),
			userMappings.getProperty("lastName"),
			userMappings.getProperty("jobTitle"),
			userMappings.getProperty("group"),
			"mobile"
		};

and then add to importLDAPUser function the following:
String mobile = LDAPUtil.getAttributeValue(attrs, "mobile");
			if(Validator.isNotNull(mobile)){
				expandoBridgeAttributes.put("mobile", mobile);		
			}


Hope it helps!
thumbnail
Nagendra Kumar Busam,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Liferay Master 帖子: 678 加入日期: 09-7-7 最近的帖子
Hi Gloria,

First of all thank you for your reply. The code what you have provided was really helpful.

One quick question: After making changes according to your inputs,i got the following error (I m hoping it was at ExpandoTableConstants.DEFAULT_TABLE_NAME). If that is the error, Please clarify me how to go ahead

10:54:56,250 ERROR [PortalLDAPUtil:876] Problem adding user with screen name testuser4 and email address btnkumar@gmail.com
java.lang.NullPointerException
at com.liferay.portlet.expando.service.impl.ExpandoValueLocalServiceImpl.addValue(ExpandoValueLocalServiceImpl.java:372)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy98.addValue(Unknown Source)
at com.liferay.portlet.expando.service.ExpandoValueLocalServiceUtil.addValue(ExpandoValueLocalServiceUtil.java:232)
at com.liferay.portal.service.impl.UserLocalServiceImpl.addUser(UserLocalServiceImpl.java:362)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


Attached the full log of the error for reference.


Thanks,
- Nagendra Kumar
Mario Fischer,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Gloria Muñoz,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 43 加入日期: 08-11-4 最近的帖子
Liferay-administration-guide-5.2.4:

there are five fields that Liferay requires to be mapped in order for the user to be recognized. You must define a mapping to the cor-
responding attributes in LDAP for the following Liferay fields:
Screen Name
Password
Email Address
First Name
Last Name


This error uses to be due to the lack of one of the attributes above. I mean, if you're trying to import a user who hasn't defined one of those attributes (he hasn't an email address associated, or Last Name..).
There are also "validator" functions implemented, which prevent some users from being imported. Eg: ScreenNameValidator.java don't allow users with underlines nor slash in their screen name to be imported.

You can check these things using "system.out" in your code..

HTH
Mario Fischer,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Gloria Muñoz,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 43 加入日期: 08-11-4 最近的帖子
..sorry, still not able to help on this, keep digging..
have you made any progress??

Cheers
Mario Fischer,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Jeff Williams,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Regular Member 帖子: 107 加入日期: 08-7-15 最近的帖子
Gloria Muñoz:
..sorry, still not able to help on this, keep digging..
have you made any progress??

Cheers


Still no-go for me. Can anyone attach an example of this working for 5.2.3?
Jeff Williams,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Regular Member 帖子: 107 加入日期: 08-7-15 最近的帖子
I'm unable to resolve expandoBridgeAttributes here, no matter what I do. Has anyone else had this problem?
Tony Lim,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 90 加入日期: 09-4-15 最近的帖子
follow the patch listed in this bug report.

http://issues.liferay.com/browse/LPS-3070
Jeff Williams,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Regular Member 帖子: 107 加入日期: 08-7-15 最近的帖子
I have used that patch, but still no-go. I'm totally stumped here.
thumbnail
srikanth arroju,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Regular Member 帖子: 133 加入日期: 09-10-3 最近的帖子
Nagendra:

java.lang.NullPointerException
at com.liferay.portlet.expando.service.impl.ExpandoValueLocalServiceImpl.addValue(ExpandoVal
ueLocalServiceImpl.java:372)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307
)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMe
thodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
cation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInte
rceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
cation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationIn
terceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
cation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy98.addValue(Unknown Source)
at com.liferay.portlet.expando.service.ExpandoValueLocalServiceUtil.addValue(ExpandoValueLoc
alServiceUtil.java:232)
at com.liferay.portal.service.impl.UserLocalServiceImpl.addUser(UserLocalServiceImpl.java:36
9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307
)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMe
thodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
cation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInte
rceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
cation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationIn
terceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
cation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy70.addUser(Unknown Source)
at com.liferay.portal.service.UserLocalServiceUtil.addUser(UserLocalServiceUtil.java:149)
at com.liferay.portal.security.ldap.PortalLDAPUtil.importLDAPUser(PortalLDAPUtil.java:954)
at com.liferay.portal.security.ldap.PortalLDAPUtil.importFromLDAP(PortalLDAPUtil.java:582)
at com.liferay.portal.security.ldap.PortalLDAPUtil.importFromLDAP(PortalLDAPUtil.java:551)
at com.liferay.portlet.admin.job.LDAPImportJob.execute(LDAPImportJob.java:62)
at com.liferay.portal.job.JobWrapper.execute(JobWrapper.java:69)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)


.



its displaying the same error after applying patch also

did anybody resolve this

please help me!

Thanks,
Srikanth A
Bruno Vernay,修改在13 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 36 加入日期: 10-4-6 最近的帖子
Isn't it the point of the following parameter in portal-ext.properties

#
# When importing and exporting users, the portal will use this mapping to
# connect LDAP user attributes and portal contact attributes.
#
# See com.liferay.portal.model.ContactModel for a list of attributes.
#
ldap.contact.mappings=


I found the ContactModel JavaDoc here:
http://docs.liferay.com/portal/6.0/javadocs/com/liferay/portal/model/ContactModel.html

I tried a few mappings like
ldap.contact.mappings=smsSn=pager\nskypeSn=homePhone

But without success !?
Bhanu P Kondeti,修改在14 年前。

RE: LDAP Mapping and Custom attributes

New Member 帖子: 6 加入日期: 09-8-6 最近的帖子
Hi Narendra,
Were you able to achieve this. I need to do the similar thing in my project. I need to import the contact information and the address information of the user from the LDAP.

Could you please share your learnings with me.

Thanks,
Bhanu
thumbnail
vikash kumar chaurasia,修改在14 年前。

RE: LDAP Mapping and Custom attributes

Junior Member 帖子: 97 加入日期: 10-1-8 最近的帖子
Hi,


My question is:

If I have created a custom attribute for User e.g. country from the control panel and set it's value as "France" for a user. How can I get that attribute value for that user in a portlet in Plugin SDK envt.

Thanks.