2011-12-12 29 views
0

嘗試獲取組中的用戶列表。我可以讓用戶在OU和東西。但是這個小組沒有工作!我已經把這個團隊從OU中提取出來,放在根本希望能夠幫到的地方,但是並沒有。無法找到組中的Windows用戶?

CN = thisisthegroup,DC = thisisthedomain,DC = com的

任何幫助,將不勝感激,我很新的LDAP。謝謝。

回答

1

你可以試試這個liek

static void Main(string[] args) 
{ 
    string groupName = "Domain Users"; 
    string domainName = ""; 

    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domainName); 
    GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, groupName); 

    if (grp != null) 
    { 
     foreach (Principal p in grp.GetMembers(false)) 
     { 
       Console.WriteLine(p.SamAccountName + " - " + p.DisplayName); 
     } 

     grp.Dispose(); 
     ctx.Dispose(); 
     Console.ReadLine(); 
    } 
    else 
    { 
     Console.WriteLine("\nWe did not find that group in that domain, perhaps the group resides in a different domain?"); 
     Console.ReadLine(); 
    } 
} 

,或者你可以嘗試在How to get Users Belonging to Active Directory group

,在這個環節中指定一個
相關問題