cancel
Showing results for 
Search instead for 
Did you mean: 

How to Get Custom LDAP Attribute in Web Dynpro for Java

Former Member
0 Kudos

Hi experts,

I need to enable/disable a text field in web dynpro depending on the user's employee type based in LDAP.

The problem is, I do not know how to pull this data since I do not know the attribute name for the employee type in LDAP.

Is there a way I could find the attribute name for this in web dynpro?

If not, how would I know this?

By the way, this is how I pulled the user's data in LDAP. But I can't pull the data for employee type since I do not know its attribute name! :

IUser l_currentUser = WDClientUser.getCurrentUser().getSapUser();

String l_loginUser = l_currentUser.getUserAccounts()[0].getLogonUid();

String l_userRegion = l_currentUser.getAttribute("com.sap.security.core.usermanagement","ExtRegion")[0];

Thanks in advance for the help!

Regards,

Vey

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear Paul,

Can you please try this code?

IWDClientUser clientUser = WDClientUser.getLoggedInClientUser();

IUser user = clientUser.getSAPUser();

String[] names = user.getAttributeNamespaces();

String[] parameter1 = user.getAttribute(names[0], "dn");

Thanks & Regards,

Patralekha

Former Member
0 Kudos

Hi Patralekha,

Thanks for the help.

May I know what "dn" is in parameter1?

I also want to preview the namespaces as a string but the context(String) cannot accept parameter1 which is String[].

Please advise...

Thanks and Regards,

Vey

Former Member
0 Kudos

Hi Patralekha,

I tried this one but I get a java.lang.NullPointerException.

StringBuffer result = new StringBuffer();

for (int i = 0; i < parameter1.length; i++) {

               result.append( parameter1[i] );

}


String mynewstring = result.toString();

wdContext.currentCtx_vn_EAttributeElement().setCtx_va_EAttribute(mynewstring);


What seems to be the problem?


Regards,

Vey

Former Member
0 Kudos

Dear Paul,

Here "dn" stands for Distinguished Name.

Is it possible to get the LDAP file from

System Administration -> System Configuration -> UME Configuration  & download to check the exact names of the custom attributes?

Thanks & Regards,

Patralekha

Former Member
0 Kudos

Hi Patralekha,

Upon checking the UME Configuration,

I was able to get this:

<principal type="user">

     <nameSpaces>

          <nameSpace name="com.sap.security.core.usermanagement">

               <attributes>

                    <attribute name="employeeType">

                    <physicalAttribute name="employeeType"/>

               </attribute>

...

Here is the code I used to get the attribute:

String l_userAtt = l_currentUser.getAttribute("com.sap.security.core.usermanagement","employeeType")[0];

wdContext.currentCtx_vn_EAttributeElement().setCtx_va_EAttribute(l_userAtt);

But upon trying to get this specific attribute, I still get the NullPointerException...

Thanks and Regards,

Vey

Former Member
0 Kudos

Hi Patralekha,

I have solved the issue.

It seems that I did something wrong with my context attribute.

Thanks for the help!

Regards,

Vey

Former Member
0 Kudos

Dear Paul,

Great Job.

You are most welcome.

Thanks & Regards,

Patralekha