cancel
Showing results for 
Search instead for 
Did you mean: 

Getting user groups from LDAP

Former Member
0 Kudos

Hi All,

I'm using this code to get the User's group

try

{

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

myGroups = user.getAttribute("com.sap.security.core.usermanagement.relation","PRINCIPAL_RELATION_PARENT_ATTRIBUTE");

}

catch{

}

For some users I'm getting "No Text availble " or nullpointer exception.

The code used to run with je22 sp 13 with no problem but after upgrading to SP19, some user get this message !!!

Thanks,

Amit Yosha

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

This code returns the iterator containing the user groups. Once you have called it, you have to loop this iterator while hasnext = false.

<b> try{

IWDClientUser clientuser = WDClientUser.getCurrentUser();

IUser user = clientuser.getSAPUser();

Iterator userGroups = null;

userGroups = user.getParentGroups(true);

}

catch(Exception ex){

wdThis.wdGetAPI().getComponent().getMessageManager().raiseMessage( IMessageYSP_CRM_CP_COCKPIT.USER_E , null,true);

}</b>

userGroups has the groups.

Don't forget to loop the iterator in try statement.

Hopes it can work.

Grites!

former_member182374
Active Contributor
0 Kudos

Hi Amit,

It depends where the attrbiute is being saved:

1) If it's saved in LDAP you need to check your dataSourceConfiguration file (check that you have the namespace 'com.sap.security.core.usermanagement.relation' and the property 'PRINCIPAL_RELATION_PARENT_ATTRIBUTE' is properly mapped to physical attribute in the LDAP).

2) If it's saved in the Portal DB, check that the portal actually saves this property for a user (by using setAttribute and then getAttribute...)

Regards,

Omri

former_member751941
Active Contributor
0 Kudos

Hi Yosha,

Your NWDS version and WAS version should be same.

check this thread.

Regards,

Mithu