Hi @john john ,
Yes,you can do that.
You can pass the LDAP string via DirectoryEntry.
https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.directoryentry.-ctor?view=windowsdesktop-7.0#system-directoryservices-directoryentry-ctor(system-string-system-string-system-string
You can do this:
var directoryEntry = new DirectoryEntry("LDAP://***");
directoryEntry.Username = "***";
directoryEntry.Password = "***";
Then you can query "AD" using the DirectorySearcher.
var directorySearcher = new DirectorySearcher(directoryEntry);
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.