C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Getting LDAP Retrievals Posted by geraldbauer on 29 Aug 2003 at 6:41 AM
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.
Report
Re: Getting LDAP Retrievals Posted by geraldbauer on 5 Sept 2003 at 9:03 AM
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?
Report
Re: Getting LDAP Retrievals Posted by LexC on 10 Sept 2003 at 7:01 AM
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
Report
Re: Getting LDAP Retrievals Posted by geraldbauer on 11 Sept 2003 at 9:24 AM
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.
Report
Re: Getting LDAP Retrievals Posted by LexC on 12 Sept 2003 at 6:02 AM
: 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
Report
Re: Getting LDAP Retrievals Posted by emaino on 22 Sept 2003 at 7:40 PM
In this code:
searcher.PropertiesToLoad.Add("freeFormName"); 
searcher.PropertiesToLoad.Add("title"); 
searcher.PropertiesToLoad.Add("personID");


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..
searcher.PropertyNamesOnly = true
will only return a property if it has a set value in it, this may be why you are only getting ADSPath returned.



Eric Maino
GVSU Microsoft SA

Report
Re: Getting LDAP Retrievals Posted by geraldbauer on 25 Sept 2003 at 8:35 AM
:
: searcher.PropertiesToLoad.Add("freeFormName"); 
: searcher.PropertiesToLoad.Add("title"); 
: searcher.PropertiesToLoad.Add("personID");
: 

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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.