Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Get DistinguishedName of an LDAP entry given a uid  RSS feed

 
hooplehead swearengine
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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){}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!