我很惊讶我无法通过组名查找Windows组成员身份。
我可以用 UserPrincipal.Current.GetGroups(); 但我显然不能使用 Httpcontext.CurrentUser.IsInRole
按名称查找组成员资格,以确定当前用户是否在组中。
var groups = UserPrincipal.Current.GetGroups();
var groupNames = groups.Select(x => x.SamAccountName);
var check0 = groupNames.Contains("pgXbCreateScanDefn"); //works but is not the way by supporting classes currently check.
//this is how my supporting classes expect to check membership
var principal = HttpContext.Current.User;
var check = principal.IsInRole("pgXbCreateScanDefn"); //expected to be true but is not
//while this works, I would have to translate the user friendly names to SIDs.
var check2 = principal.IsInRole("S-1-5-21-4052565669-1266607236-977642746-1013"); //is true as expected,
过去我能做到这一点。这不再受支持了吗?