I've implemented an object factory to lookup LDAP objects, but the supplied context does not return the DN (via nameCtx.getNameInNamespace()) from the LDAP. Am i doing it wrong in some way?
public class LdapPersonFactory implements DirObjectFactory {
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment, Attributes attrs) throws Exception {
if (attrs == null)
return null;
Attribute oc = attrs.get("objectclass");
if (oc != null && oc.contains("inetOrgPerson")) {
String surname = (String) attrs.get("sn").get();
String givenName = (String) attrs.get("givenname").get();
String dn = nameCtx.getNameInNamespace();
return new LdapPerson(dn, givenName, surname);
}
return null;
}
}
nameCtx.getNameInNamespace() only returns an empty string.