Query Active Directory Fast
Let's say I have a list of SID.
Currently I'm qu开发者_StackOverflowerying the AD for each SID. Something like
foreach(string sidString in listOfSid)
{
DirectorySearcher search = new ....
search.Filter = string.Format("(objectSid={0})", ConvertToOctetString(sidString));
var result = search.FindOne();
.....
}
Is there a faster way than this? Instead of looping is there a way to query all informations in one shot instead of the loop?
I'm not sure I understand your question, but why don't you build a filter in a loop and then search one time. The filter will look like :
(|(objectSid=sid1)(objectSid=sid2)(...)(objectSid=sidn))
If you've got .NET 3.5 or higher, then you can work with principals.
According to How Active Directory Searches Work, the maximum LDAP request size that the server attempts to process is 10485760 bytes. If the server receives a request that is larger than this value, it closes the connection. Having said that, I never tested it.
精彩评论