cancel
Showing results for 
Search instead for 
Did you mean: 

Ldap Authentication

Former Member
0 Kudos

I am not using the standard login for the portal. I have to connect to the ldap through code and check the presence of the user and passwd in the ldap.

Kindly advice

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can configure the LDAP to authenticate the user instead of using the portal database as the user store.

Either you can do that in the config tool or do it from the portal.

In the portal system administration->um Configuration

Give the dataSource. There are xml files that you can select for each compatible LDAP servers.

Then you can give the LDAP configurations... i.e the server name, the port no. eg. 386 without encryption etc...

Once you save it and restart the server then on the authentication is done in the LDAP.

do revert back for clarifications.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Well this link should help you do it step by step.

http://help.sap.com/saphelp_nw04/helpdata/en/48/d1d13f7fb44c21e10000000a1550b0/content.htm

let me know if that was helpful. If you have problems in the steps let me know and i will be able to help you out.

regards

Ravi

Former Member
0 Kudos

Hi Alex,

I am not very sure if you need only the code for extracting the user information or need to know how to connect to an external LDAP. In case you need to know about configuring LDAP:

we can point to an external LDAP server either through the config tool or through Enterprise Portal.

1) Config tool : This link says how to configure the LDAP source through config tool. http://help.sap.com/saphelp_nw04/helpdata/en/eb/00954081efb90ee10000000a155106/content.htm

(See the example towards the end of the page)

2) Through EP : This wonderful presentation says how to do it in the EP way :

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/49a2bb90-0201-0010-eeb6-ff8...

When we change the LDAP server to an external one using the config tool or EP, the change takes place internally. i.e only the backend server changes. Still we can use the same user management apis provided by SAP. So there would be no change in the code if the LDAP is an external one or the default internal one.

A sample code to browse through the UME and check if there exists a useraccount with the supplied credentials is as follows:

Let the userName & password be stored in String variables 'userName' and 'pass' respectively.

ISearchResult rst=UMFactory.getUserFactory().getUniqueIDs();

IUser iuser=null;

String logonID = "";

boolean password_check = false;

while(rst.hasNext())

{

iuser=UMFactory.getUserFactory().getUser(rst.next().toString());

IUserAccount[] accounts = iuser.getUserAccounts();

for(int j=0;j

{

logonID = accounts[j].getLogonUid(); // retrieves the logon id

if(logonID.equals(userName))

password_check = accounts[j].checkPassword(pass); // checks for the password

if(password_check)

break;

}

if(password_check) break;

}

if(password_check)

wdComponentAPI.getMessageManager().reportSuccess("Authenticated User");

else

wdComponentAPI.getMessageManager().reportSuccess("User not authenticated");

Before using this code, you need to add security api to your project's buildpath. For that, in your NWDS, navigate to Your_project->properties->Java Build path->Libraries->Add variable->Click on Eclipse Home->extend->plugins->com.sap.security->lib->com.sap.security.api.jar.

I couldn't try this code using an external LDAP, but I hope it works for you

Hope this helps you,

Best Regards,

Nibu.