Hi,
I'm trying to find the most efficient way to get the Distinguished Name of an LDAP entry given some attribute of that entry (ie, 'uid'). That is, assume each entry in the directory has an attribute 'uid' that is unique across all entries. How do I get that entry's DN?
Here's some code to put it in perspective:
// assume InitialContext 'ctx' is created
String uid = "myuniqueid";
Attributes matchAttrs = new BasicAttributes(true);
matchAttrs.put(new BasicAttribute("uid", uid));
try {
NamingEnumeration answer = ctx.search("ou=sales,
dc=scotts_ldap_server", matchAttrs);
// how do I get the DN out of the answer?
} catch (Exception e){}
I'm trying to find the most efficient way to get the Distinguished Name of an LDAP entry given some attribute of that entry (ie, 'uid'). That is, assume each entry in the directory has an attribute 'uid' that is unique across all entries. How do I get that entry's DN?
Here's some code to put it in perspective:
// assume InitialContext 'ctx' is created
String uid = "myuniqueid";
Attributes matchAttrs = new BasicAttributes(true);
matchAttrs.put(new BasicAttribute("uid", uid));
try {
NamingEnumeration answer = ctx.search("ou=sales,
dc=scotts_ldap_server", matchAttrs);
// how do I get the DN out of the answer?
} catch (Exception e){}