私が取り組んでいる ASP.NET プロジェクトでは、管理者がデータベースにいくつかの役割を設定しています。これらのロールをユーザー プリンシパル クレームで比較する必要があります。
現時点では、すべての 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 からのものであり、多くのクレームがあります。
アプリケーションのroleNames を に変換する方法はありますか? 基本的に を名前GroupSID
に変換するプロセスをスキップできますか?GroupSID
擬似コード:
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