![](/img/trans.png)
[英]AD Group authorization not working in IIS in Blazor Server application
[英]Blazor Server AD Group Authentication - Not authorized
我正在嘗試使用 Active Directory 組保護我的 Blazor 服務器應用程序中的某些頁面。
我在 AD 中設置了一個類型為“Security”的組,並記下了 Object Id。
在 Startup.cs 我有以下代碼:
services.AddAuthorization(options =>
{
options.AddPolicy("WarehouseUser", policy =>
policy.RequireClaim("directoryGroup", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"));
// By default, all incoming requests will be authorized according to the default policy
options.FallbackPolicy = options.DefaultPolicy;
});
我裝飾了我的 index.razor 如下:
@attribute [Authorize(Policy = "WarehouseUser")]
但是,當我點擊索引頁面時,即使我絕對是 AD 中該組的成員,我也會收到錯誤消息
未經授權
我還確認,對該組織的索賠在未受保護的頁面中出現了以下代碼:
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
ClaimsPrincipal user = authState.User;
var g2 = user.Claims.Where(x => x.Type.Equals("groups")).ToList();
任何人都可以提供任何幫助嗎?
找到了!
Startup.cs 中的代碼應該是這樣的:
options.AddPolicy("WarehouseUser", policy =>
policy.RequireClaim("groups", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"));
directoryGroup應該是組
高溫高壓
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.