IPrincipal
複数のアプリケーションで使用したいカスタムを実装しています。方法について2つ質問がありIsInRole
ます...
1) カスタムでカスタム RoleProvider を使用することをお勧めしますIPrincipal
か? ユーザーの役割をチェックするロジックは、IPrincipal から継承するクラスにいつでも配置できます。
何かのようなもの:
public class SSDSPrincipal : IPrincipal
{
public SSDSPrincipal(SSDSIdentity identity)
{
this.Identity = identity;
}
public IIdentity Identity {get;private set;}
public bool IsInRole(string role)
{
string[] roles = Roles.Providers["SSDSRoleProvider"].GetRolesForUser(Identity.Name);
return roles.Any(s => role.Contains(s));
}
}
2) これを複数の MVC3 アプリケーションで使用したいため。アプリケーション名を保存するのに最適な場所はどこですか? これを手動で設定できるようにする必要があります。
public bool IsInRole(string role)
{
string applicationName = [where can I store this globally for my asp.net mvc3 app]
return AreTheyInARoleForThisApplication(applicationName, role);
}