Last post Jul 07, 2013 12:07 PM by ronenfe
Jul 07, 2013 06:34 AM|ronenfe|LINK
Hi, I set DirectoryEntry to be secured, and use it to create a new DirectorySearcher and use this object with FindOne.
I use WireShark to inspect the communication
Even Though the directoryentry binding is secured and uses port 636, when searching with the FindOne the communication is unsecured and uses port 389. Anyone knows why is that?
Attached is a sample code:
I also tried specifying the 636 port in the path explicitly but it's still the same.
DirectoryEntry entry = new DirectoryEntry(ADPath + DomainName);
entry.AuthenticationType |= AuthenticationTypes.SecureSocketsLayer;
// Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search = new DirectorySearcher();
search.Filter = filterExp;
SearchResult result = search.FindOne();
Jul 07, 2013 09:23 AM|bmwz9|LINK
See below page it may help you
Jul 07, 2013 12:07 PM|ronenfe|LINK
Thanks, the problem there is different as he couldn't make a secure connection at all. I am able to make it, but the directorysearcher connects with port 389 instead of 636, although I set the directoryentry authentication to ssl.
I tried after reading it to set a username and password the directoryentry but it's the same.
That was stupid, I found the problem, the constructor of the DirectorySearcher was called twice, the second time without the DirectoryEntry object as a parameter, so it didn't use its configurationץ
Now i read it uses the root of the currently logged domain if SearchRoot is null . Is it possible to set it secured without setting the SearchRoot with a DirectoryEntry that is set as secured?