websphere-libertyopen-liberty

Configure Liberty to expose User Registry over JNDI


I'm actually trying to resolve this problem.

I'm thinking if I can access the user registry (whatever java API it has) from inside my application, through JNDI.

Googling around I found the following code for WAS classic:

import com.ibm.websphere.security.UserRegistry;

{
  Context ic = new InitialContext();
  Object objRef = ic.lookup("UserRegistry");
  UserRegistry userReg = (UserRegistry)PortableRemoteObject.narrow(objRef, UserRegistry.class);
  ...
}

CAUTION: I don't know if this code works. I haven't tested it.

But "UserRegistry" is not available in JNDI's root context. As of now, my server lists the following bindings: "ejb", "jdbc", "services" plus some other private bindings we have in our server.xml.


Solution

  • rslemos Liberty provides User Registry APIs. I'm not sure if they align with your goals, but sharing them below for your review.

    https://openliberty.io/docs/modules/reference/23.0.0.8/com.ibm.websphere.appserver.api.securityClient_1.1-javadoc/com/ibm/websphere/security/UserRegistry.html