4

I am surprised that I cannot look up Windows group membership by the group name.

I can use UserPrincipal.Current.GetGroups(); But I aparently cannot use Httpcontext.CurrentUser.IsInRole

to look up the group membership by name to determine if the current user is in a group.

  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, 

I was able to do this in the past. Is this no longer supported?

0 Answers0