당신이 .NET 3.5 및 최대에있어 있기 때문에, 당신은 System.DirectoryServices.AccountManagement
(S.DS.AM) 네임 스페이스를 확인해야합니다. AD에서 사용자 및/또는 그룹을 쉽게 찾을
Managing Directory Security Principals in the .NET Framework 3.5
기본적으로
이 어셈블리 System.DirectoryServices.AccountManagement
에 대한 참조를 추가 한 다음 도메인 컨텍스트를 정의하고 : 여기에 대한 모든 읽기
using System.DirectoryServices.AccountManagement;
public List<GroupPrincipal> GetGroupsForUser(string username)
{
List<GroupPrincipal> result = new List<GroupPrincipal>();
// set up domain context - if you do a lot of requests, you might
// want to create that outside the method and pass it in as a parameter
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find user by name
UserPrincipal user = UserPrincipal.FindByIdentity(username);
// get the user's groups
if(user != null)
{
foreach(GroupPrincipal gp in user.GetAuthorizationGroups())
{
result.Add(gp);
}
}
return result;
}
새로운 S.DS.AM을 사용하면 광고에서 사용자 및 그룹과 놀아 볼 수 있습니다.
문제가있는 코드를 게시하면 도움이 될 수 있습니다. – SGarratt