Jothi
Jothi

Reputation: 15090

How to get user details from Websphere UserRegistry

How to fetch the user's other details from AD after logging into the application using LDAP registry configured in WebSphere server. I have Java EE application, which is using the single sign on. I want to get the other details like email, office location of the user which is configured in Active Directory. How do I get that?

        // Retrieves the default InitialContext for this server.
        javax.naming.InitialContext ctx = new javax.naming.InitialContext();

        // Retrieves the local UserRegistry object.
        com.ibm.websphere.security.UserRegistry reg = (com.ibm.websphere.security.UserRegistry) ctx
                .lookup("UserRegistry");

From this registry, is there chance to get it?

Upvotes: 1

Views: 6614

Answers (2)

Andreas Veithen
Andreas Veithen

Reputation: 9154

I wrote an article about exactly that question:

http://veithen.github.io/2012/12/13/retrieving-custom-user-attributes-from.html

Note that the conclusion is compatible with what Carlos wrote: you have to use VMM.

Upvotes: 0

Carlos Gavidia-Calderon
Carlos Gavidia-Calderon

Reputation: 7253

In WebSphere Application Server you can access User Registry information -and modify it- thorugh the Virtual Member Manager componente an its API.

There's plenty of documentation and samples on IBM Infocenter. From there, the code snippet to get the properties of an entity like a user:

DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_PERSON_ACCOUNT);
entity.createDataObject(DO_IDENTIFIER).set(PROP_UNIQUE_NAME, 
                             "uid=SalesManager,cn=users,dc=yourco,dc=com");
DataObject propCtrl = SDOHelper.createControlDataObject(root, null, DO_PROPERTY_CONTROL);           
propCtrl.getList(PROP_PROPERTIES).add("sn");
propCtrl.getList(PROP_PROPERTIES).add("uid");
propCtrl.getList(PROP_PROPERTIES).add("cn");
propCtrl.getList(PROP_PROPERTIES).add("telephoneNumber");
propCtrl.getList(PROP_PROPERTIES).add("createTimestamp");

root = service.get(root);

To get the service instance that communicates with the registry you need first to execute the Programming Prerequisites of the API. I stringly suggest you to review the Infocenter documentation.

Upvotes: 2

Related Questions