Quick search in Active Directory

Let's say I have a list of SID.

I am currently requesting AD for each SID. Sort of

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 there is a way to request all the information in one shot instead of the cycle?

+4
source share
1 answer

I'm not sure I understand your question, but why do not you create a filter in the loop, and then look for a time. The filter looks like this:

 (|(objectSid=sid1)(objectSid=sid2)(...)(objectSid=sidn)) 

If you have .NET 3.5 or higher, you can work with the principals .

According to How does the search Active Directory system , the maximum size of the LDAP query that tries to perform the server is 10485760 bytes. If the server receives a request, which is greater than this value, it closes the connection. Having said that, I have never tested it.

+5
source

All Articles