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

geraldbauergeraldbauer Posts: 7Member
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

  • geraldbauergeraldbauer Posts: 7Member
    I discovered that the code
    searcher.PropertyNamesOnly = true;
    needed to be
    searcher.PropertyNamesOnly = false;

    My next issue is that the LDAP server is sending me a System.NotImplementedException exception with the message of "Handling of this ADSVALUE type is not yet implemented (type = 0xb)."

    Anyone seen this before?
  • LexCLexC Posts: 10Member
    I have a question on LDAP.
    Here is the scenario: I am logged on to Top domain and the server that the web application is running on in on a SecondLevel domain (subtree).
    I access the web application a workstation and the application uses Global Catalog (DirectoryEntry("GC//")) to get my information from Active Directory. I can't seem to get any information back. I get a message that the server is not operational.

    Could you shed some light on what is going on?

    Thanks
  • geraldbauergeraldbauer Posts: 7Member
    I was getting that message when my path was not set right. It could not find the server. What about authenticating yourself? Have you tried that?

    Hope this is helpful.
  • LexCLexC Posts: 10Member
    : I was getting that message when my path was not set right. It could not find the server. What about authenticating yourself? Have you tried that?
    :
    : Hope this is helpful.
    :

    How do I authenticate myself?
    Also....Can I search a different domain from the one I have my account in? if so, How?

    Thanks
  • emainoemaino Posts: 48Member
    In this code:
    [code]
    searcher.PropertiesToLoad.Add("freeFormName");
    searcher.PropertiesToLoad.Add("title");
    searcher.PropertiesToLoad.Add("personID");
    [/code]

    Are you positive that those three values exist in AD? I am not familar with them, though I am also not an AD guru though I have done quite a bit of work with AD, through ADSI.

    Also the following line of code..
    [code]
    searcher.PropertyNamesOnly = true
    [/code]will only return a property if it has a set value in it, this may be why you are only getting ADSPath returned.



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

  • geraldbauergeraldbauer Posts: 7Member
    : [code]
    : searcher.PropertiesToLoad.Add("freeFormName");
    : searcher.PropertiesToLoad.Add("title");
    : searcher.PropertiesToLoad.Add("personID");
    : [/code]
    These properties are user defined. They are not supported. I have been told that I must go after the native APIs. I am confused as to why and how.
Sign In or Register to comment.