문제

주어진 SID가 .NET을 사용하여 사용자 또는 그룹인지 여부를 결정할 수 있습니까? 목록 뷰에서 편집 해야하는 Sids 목록이 있으므로 사용자 및 그룹에 대해 다른 아이콘을 사용하고 싶습니다

도움이 되었습니까?

해결책

System.DirectoryServices.AccountManagement를 사용하여 시도해 볼 수 있습니다.

//Get NTAccount, to find out username and domen
NTAccount nt = (NTAccount)sid.Translate(typeof(NTAccount));
string[] fullName = nt.Value.Split(new char[] { '\\' });

//then get group principle
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, fullName[0]);
GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, fullName[1]);

//and check whenever this group exists
bool SidIsAGroup = grp != null;
.

비슷한 질문 (그리고 답변)을 찾을 수 있습니다. Active Directory에서 사용자 그룹을 가져 오는 방법은 무엇입니까?(C #, ASP.NET)

다른 팁

lookupccountsid () 함수는 계정의 유형을 나타내는 sid_name_use 값을 반환합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top