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 + "\r");
}
}
}
}
catch(Exception e){Console.WriteLine(e.Message + "\r\r" + 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.