2011-12-12 5 views
0

그룹의 사용자 목록을 얻으려고합니다. OU에있는 사용자를 얻을 수 있습니다. 그러나 그룹은 작동하지 않습니다! 나는 OU에서 그 그룹을 빼앗아 도움이 될 수 있기를 희망하는 뿌리에 넣었지만 그렇게하지는 않았다.그룹에서 Windows 사용자를 찾을 수 없습니까?

CN = thisisthegroup는, DC = thisisthedomain, DC는 = co.kr에서 어떤 도움을 주시면 감사하겠습니다

, 나는 LDAP에 아주 새로운 해요. 감사.

답변

1

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(); 
    } 
} 

liek 시도 할 수 있습니다 또는 How to get Users Belonging to Active Directory group

에 하나이 링크에 지정된 것을 시도 할 수 있습니다
관련 문제