How to authenticate ldap when it is not connected to a domain in Microsoft Active Directory using C #

For some reason, ldap and directory services do not work when the computer is not connected to a domain. Error messages from .net are not available for the domain. Does anyone know what needs to be done?

main...

 domainAndUsername = domain + @"\" + username;
 entry = new DirectoryEntry(_path, domainAndUsername, pwd);
 entry.AuthenticationType = FindAuthTypeMicrosoft(authType);

... doesn't seem to work when logging in locally when trying to put testdomain.com on the code above.

Even if I can ping testdomain.com without any problems. What else or problem?

+3
source share
3 answers

This code worked for me in the past (although I admit that I can’t check it right now):

DirectoryEntry entry = new DirectoryEntry("LDAP://server-name/DC=domainContext,DC=com");
entry.Username = @"DOMAIN\account";
entry.Password = "...";
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(&(objectClass=user)(sn=Jones))";
SearchResultCollection results = searcher.FindAll();

( ) " ". ADSI Edit AD Explorer , . Softerra LDAP Browser - , v2.6 .

+3

ActiveDirectory. . , . ActiveDirectory.

0

I left _path empty. Sorry, my own problem.

0
source

Source: https://habr.com/ru/post/1708195/


All Articles