I posted this question up on SO (here: http://stackoverflow.com/questions/20957243/cannot-list-all-ldap-attributes-using-c-sharp), but thought the MSDN forums might be more responsive in getting this answered. I hope that was an alright, decision; if not, please let me know I'll take one of the posts down.
I am trying to get a list of all attributes for a given LDAP entry, with the following code:
LdapConnection conn = GetOpenLdapConnection(); string filter = "(uid=" + user + ")"; SearchRequest search = new SearchRequest(LDAP_BASE, filter, SearchScope.Subtree, "*"); SearchResponse resp = conn.SendRequest(search) as SearchResponse; SearchResultEntry entry = resp.Entries[0];Console.WriteLine(entry.DistinguishedName); foreach (string attr in entry.Attributes.AttributeNames) Console.WriteLine("Name:" + attr);
conn.Dispose();
However, this only prints one attribute name: "uid". I'm confused as to why this is not returning all of the attributes that I can clearly see using an LDAP browser (browsing the same entry for the given user as the code is attempting to retrieve).
Honestly, I don't care to see all the attributes; I know the names of the ones I want to retrieve, but even if I replace new SearchRequest(..., "*") with new SearchRequest(..., "attr1", "attr2", "etc."), the only one
I can seem to retrieve is "uid". Is there something obvious here I am missing?
BTW, I get the same behavior if I use "DirectorySearcher"; it only wants to display the single "uid" attribute.