1
ASP.NET 프로젝트에서 저는 관리자로 데이터베이스에 몇 가지 역할을 설정했습니다. 사용자 역할 클레임에 따라 이러한 역할을 비교해야합니다. 내가 해당 이름으로 모든 GroupSID 년대를 변환하고있어 순간응용 프로그램의 역할을 groupsid로 변환
:
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, IdentityType.Sid, sid);
if (_roleNames.Exists(r => string.CompareOrdinal(r, group.SamAccountName) == 0))
{
groupName = group.SamAccountName;
return true;
}
_roleNames
는 역할을 포함 문자열의 목록입니다.
_roleNames.Add("Read");
_roleNames.Add("Edit");
_roleNames.Add("Review");
_roleNames.Add("Publish");
문제는이 프로세스가 매우 느립니다. 교장은 Active Directory를 사용하고 있으며 많은 주장을하고 있습니다.
내가 그들의 이름에 GroupSID
변환 어디 그래서 기본적으로 과정을 건너 뛸 수있는 GroupSID
에 내 응용 프로그램에서 roleNames 를 변환하는 방법이 있나요?
의사 코드 :
을 대신 난 그냥이 같은 그룹 명 전달 된 GroupPrincipal에 SID를 통과 :
list<string> roleSidList
foreach role in roleList
roleSidList.add(role.ConvertToSid())
foreach claim in Principal.Claims
if(roleSidList.Exists(r => r == claim))
// role exists, do something with it