Getting LDAP Retrievals - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Getting LDAP Retrievals

I am accessing an LDAP server and I am only getting one property back, the adspath property, when I have requested three other properties (the adspath is added to the property list by default). Not sure what I am doing wrong. Here is a snipit of the code:

public void StartSearch(){
DirectoryEntry entry = new DirectoryEntry("LDAP://ldap.server.name:389/ou=Users, ou=Company Name, o=company, c=us");
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.SearchScope = SearchScope.Subtree;
searcher.ServerTimeLimit = new TimeSpan(8000);
searcher.PropertyNamesOnly = true;
searcher.PropertiesToLoad.Add("freeFormName");
searcher.PropertiesToLoad.Add("title");
searcher.PropertiesToLoad.Add("personID");
searcher.Filter ="(personID=14143126)";
try{
SearchResultCollection queryResults = searcher.FindAll();
foreach(SearchResult result in queryResults){
ResultPropertyCollection rpc = result.Properties;
foreach(string colName in rpc.PropertyNames){
foreach(object values in rpc[colName]){
Console.WriteLine(values + "
");
}
}
}
}
catch(Exception e){Console.WriteLine(e.Message + "

" + e.ToString());}
}
I am only getting one values object back, it is the "adspath" that is the path of the LDAP with answers to the ??= as seen in the path. It shows that I have four properties and four PropertiesToLoad.

What have I forgotten to do?

Thank you.

Comments

  • emainoemaino Posts: 48Member
    My guess as to why you are only seeing the adsPath coming back is for two reasons.

    1. Is that searcher.PropertyNamesOnly is set to true. When this value is set to true the DirectorySearcher will only return properties that have acutal values in them.

    2. I do not think that defaultly any of the properties you are searching for exist in AD. I have run the search against a few of my acceessible ADs and I do not see any of these properties available.



    [size=3][italic]Eric Maino[/italic][/size]
    [b][blue]GVSU[/blue] Microsoft SA[/b]

Sign In or Register to comment.