0

I'm using Windows Authentication and AD groups as roles. I got the following to work:

@User.IsInRole("DOMAIN\ADGroupName")

After some testing, it seems this only works with the Display Name, not the Alias of the AD group. Most groups in our domain have complex naming like:

@User.IsInRole("DOMAIN\*DEPT/TEAM/A&BC Developers")

This returns false, even if you are in a group with the same name. How can I get @User.IsInRole("") to recognize such complex group names?

ArunPratap
  • 4,816
  • 7
  • 25
  • 43
Ali Almohsen
  • 1,311
  • 3
  • 13
  • 24

1 Answers1

0

Try adding a @ as a prefix to your string:

@User.IsInRole(@"DOMAIN\*DEPT/TEAM/A&BC Developers")

Or if you assign the string to a variable ahead of time:

@{
    string group = @"DOMAIN\*DEPT/TEAM/A&BC Developers";
}

@User.IsInRole(group)
Versailles
  • 441
  • 2
  • 6