Last post Mar 24, 2017 06:16 AM by Chris Zhao
Mar 23, 2017 08:54 AM|net fan|LINK
I have a .Net application that reads user from active directory that is in a specific OU (ABCUsers). The following is the code:
string DomainIP = "some domain IP";
string ContainerConnectionString = "OU=ABCUsers,DC=test,DC=com";
PrincipalContext domain = new PrincipalContext(ContextType.Domain, DomainIP, ContainerConnectionString, ContextOptions.SimpleBind);
PrincipalSearcher searcher = new PrincipalSearcher();
UserPrincipal findUser = new UserPrincipal(domain);
findUser.SamAccountName = "some username";
searcher.QueryFilter = findUser;
UserPrincipal foundUser = (UserPrincipal)searcher.FindOne();
The above code works fine, but I need to change the code so that it retrieves a user whether he/she is in OU=ABCUsers or OU=XYZUsers but not in any other OU.
Any help is appreciated.
Thanks in advance
Mar 24, 2017 06:16 AM|Chris Zhao|LINK
Hi net fan,
Please take a look at the following SO link.
LDAP root query syntax to search more than one specific OU