[英]Missing Group Built-in Administrators (SID: S-1-5-32-544) in HttpContext.User.Identity
I am using windows authentication and want to know if an logged in user belongs to the group 'Built-in Administrators'.我正在使用 Windows 身份验证并想知道登录用户是否属于“内置管理员”组。 I am using the following code snipped to find that out in my MVC4-Application:
我正在使用以下代码在我的 MVC4-Application 中找到它:
// user identity
var lIdentity = HttpContext.User.Identity as WindowsIdentity;
// get all Group-Sids, the current users belongs to.
var lSids = lIdentity.Groups;
The group Built-in Administrators (SID S-1-5-32-544) is not listed in lSids
.组内置管理员 (SID S-1-5-32-544) 未在
lSids
列出。
But when I use the cmd whoami /groups
on the same user, it shows the SID S-1-5-32-544.但是当我在同一用户上使用 cmd
whoami /groups
时,它显示 SID S-1-5-32-544。
How can I find out in my MVC4, if an logged-in user belongs to the Build-In Administrators group.如何在我的 MVC4 中找出登录用户是否属于 Build-In Administrators 组。
You can achieve that by accessing Claims instead of Groups.您可以通过访问 Claims 而不是 Groups 来实现这一点。
Here is how to do that:以下是如何做到这一点:
var claims = lIdentity.Claims;
var claimSids = claims.Select(claim => claim.Value).ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.