0
在我使用角度js構建的ASP.Net MVC SPA中,我想根據用戶是否在特定安全組中顯示或隱藏鏈接或不。我打算在html頁面中使用ng-if指令來顯示或隱藏。如何獲得用戶使用的安全組列表
在我以前的純MVC.net應用程序的項目中,我有下面的方法讓我看到這個安全組列表。
但我該如何在angularjs應用程序中做到這一點?目前,我的應用程序位於雲端,它根據Azure Active Directory對用戶進行身份驗證。
internal static IEnumerable<string> GetSecurityGroups()
{
try
{
ClaimsPrincipal claimsPrincipal = null;
claimsPrincipal = Thread.CurrentPrincipal as ClaimsPrincipal;
claimsPrincipal = ((claimsPrincipal == null) && (HttpContext.Current.User != null))
? HttpContext.Current.User as ClaimsPrincipal
: claimsPrincipal;
if (claimsPrincipal != null)
{
return ((ClaimsIdentity)claimsPrincipal.Identity).Claims
.Where(
claim =>
"group".Equals(claim.Type.Replace("http://sts.tmft.net/user/", ""),
StringComparison.InvariantCultureIgnoreCase))
.Select(c => c.Value).ToList();
}
}
catch (Exception exception)
{
Log.Error(exception);
}
return new[] { "No rights" };
}