问题
I have the following code:
var directoryEntry = new DirectoryEntry(distributionListsListADSPath);
var directorySearcher = new DirectorySearcher(directoryEntry)
{ SizeLimit = int.MaxValue, PageSize = int.MaxValue };
var result = directorySearcher.FindAll();
The problem is I want to search two seperate OUs.
So what I do is run through this twice, once where
private const string distributionListsListADSPath =
"LDAP://OU=Distribution Lists,OU=Groups,DC=enron,DC=com";
and a second where it is
private const string distributionListsListADSPath =
"LDAP://OU=Security Groups,OU=Groups,DC=enron,DC=com";
Ideally, I could do something like
private const string distributionListsListADSPath =
"LDAP://OU=Distribution Lists | OU = Security Groups ,OU=Groups,DC=enron,DC=com";
回答1:
Without knowing the hierarchy of your container, it is hard to form a proper answer.
You may need to use Extensible Match which is described here: http://ldapwiki.willeke.com/wiki/ExtensibleMatch
Good Luck -jim
回答2:
try this:
"(|(OU=Distribution Lists)(OU=Security Groups,OU=Groups,DC=enron,DC=com))"
来源:https://stackoverflow.com/questions/1540595/using-directorysearcher-to-query-multiple-ous