簡體   English   中英

HttpContext.User.Identity 中缺少組內置管理員(SID:S-1-5-32-544)

[英]Missing Group Built-in Administrators (SID: S-1-5-32-544) in HttpContext.User.Identity

我正在使用 Windows 身份驗證並想知道登錄用戶是否屬於“內置管理員”組。 我正在使用以下代碼在我的 MVC4-Application 中找到它:

   // user identity
    var lIdentity = HttpContext.User.Identity as WindowsIdentity;

    // get all Group-Sids, the current users belongs to.
    var lSids = lIdentity.Groups;

組內置管理員 (SID S-1-5-32-544) 未在lSids列出。

但是當我在同一用戶上使用 cmd whoami /groups時,它顯示 SID S-1-5-32-544。

如何在我的 MVC4 中找出登錄用戶是否屬於 Build-In Administrators 組。

您可以通過訪問 Claims 而不是 Groups 來實現這一點。

以下是如何做到這一點:

var claims = lIdentity.Claims;
var claimSids = claims.Select(claim => claim.Value).ToList();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM