开发者

Using DirectorySearcher to query multiple OUs

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 s开发者_运维问答tring 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";


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


try this:

"(|(OU=Distribution Lists)(OU=Security Groups,OU=Groups,DC=enron,DC=com))"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜