कृपया आप निम्नलिखित कोड का प्रयास कर सकते हैं। यह एक एलडीएपी क्वेरी में और फिर से प्राप्त करने के लिए Search Filter Syntax का उपयोग करें। ब्याज यह है कि सर्वर पर क्वेरी की जाती है। मुझे यकीन नहीं है कि यह @marc_s समाधान से तेज़ है लेकिन यह मौजूद है, और यह ढांचे पर काम करता है .NET 2.0 (W2K3 SP2 शुरू करना)।
string sFromWhere = "LDAP://WM2008R2ENT:389/dc=dom,dc=fr";
DirectoryEntry deBase = new DirectoryEntry(sFromWhere, "dom\\jpb", "test.2011");
/* To find all the users member of groups "Grp1" :
* Set the base to the groups container DN; for example root DN (dc=societe,dc=fr)
* Set the scope to subtree
* Use the following filter :
* (member:1.2.840.113556.1.4.1941:=CN=Grp1,OU=MonOu,DC=X)
* coupled with LDAP_MATCHING_RULE_BIT_AND on userAccountControl with ACCOUNTDISABLE
*/
DirectorySearcher dsLookFor = new DirectorySearcher(deBase);
dsLookFor.Filter = "(&(memberof:1.2.840.113556.1.4.1941:=CN=MonGrpSec,OU=MonOu,DC=dom,DC=fr)(userAccountControl:1.2.840.113556.1.4.803:=2))";
dsLookFor.SearchScope = SearchScope.Subtree;
dsLookFor.PropertiesToLoad.Add("cn");
SearchResultCollection srcUsers = dsLookFor.FindAll();
/* Just to know if user is present in an other group
*/
foreach (SearchResult srcUser in srcUsers)
{
Console.WriteLine("{0}", srcUser.Path);
}
मैं यह जोड़ना भूल गया कि मैं .NET 4 पर हूं (वैकल्पिक रूप से 3.5) –