Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.