Questions tagged [isinrole]

IsInRole is a method of the WindowsPrincipal class found in the System.Security.Principal namespace of Microsoft's .NET framework. It has several overloads and returns a boolean value that indicates if the principal object is member of a particular group.

Tag Usage

The tag naturally should be applied to any questions regarding the usage of the method.

Sample Questions

Resources

To learn more, read the official documentation on Docs.

31 questions
15
votes
2 answers

Usage of User.IsInRole() in a View

In my mvc5 project to disable an action link for unauthorized users i did like this @if (User.IsInRole("Admin") | User.IsInRole("Manager")) { @Html.ActionLink("Add New Record", "ProductTypeIndex", "ProductType") } But if there are many…
Isuru
  • 950
  • 1
  • 13
  • 34
10
votes
2 answers

User.IsInRole("fake group") results in "The trust relationship between the primary domain and the trusted domain failed"

I have an MVC 3 app, using Windows Authentication with Claims using WIF 4.5. Access to the application is controlled (currently) via membership in an AD group: In addition to…
JoeBrockhaus
  • 2,745
  • 2
  • 40
  • 64
7
votes
2 answers

IsInRole Getting New Security Token

I'm using WindowsPrincipal's IsInRole method to check group memberships in WPF and Winforms apps. I'm generating an identity token which can be for any AD user (not necessarily the user who's actually logged into the computer--depending on what I'm…
Jeff
  • 8,020
  • 34
  • 99
  • 157
5
votes
1 answer

WindowsPrincipal.IsInRole and universal vs. global active directory groups

Does anybody know how to make WindowsPrincipal.IsInRole("domain\role") work with active directory universal groups? Let's say the current user is a member of a group called Role in a domain called domain, and that the Role group is a Global group in…
sindre j
  • 4,404
  • 5
  • 31
  • 32
4
votes
0 answers

IsInRole() not checking for nested group membership, what am i missing

Giving correct results for all the groups returned by "whoami /groups" but not for nested groups. For example userA is a member of a group A and group A is a member of Group B then it is returning true for groupName = A but not for groupName = B,…
AgentMac
  • 41
  • 3
3
votes
0 answers

User.IsInRole only works with AD Group SID (rather than Group Name)

If I only use Windows Authorization, I can easily use User.IsInRole("Web Developers") without issue. But, when I add a SQL Role Provider, User.IsInRole will only return true (for Active Directory groups) if I use the group's SID. It doesn't seem…
3
votes
2 answers

How does IPrincipal gets its roles?

I need to get know how SiteMapProvider.IsAccessibleToUser() works. Built-in XmlSiteMapProvider calls HttpContext.User.IsInRole() which uses System.Security.Principal.GenericPrincipal in case of forms authentication. Where does the current user gets…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
3
votes
1 answer

Identity 2.0 Custom UserManager/RoleManager vs razor calling User.IsInRole("RoleName")

Questions are below: read through to see what you need to help answer... I have VS 2013 MVC 5 with Razor views Dapper DAL Custom UserManager and UserStore/User : IUser< int > I build my own UserManager, RoleManager, UserStore, RoleStore, and…
Robert Achmann
  • 1,986
  • 3
  • 40
  • 66
3
votes
3 answers

Override the User.IsInRole and [Authorize(Roles = "Admin")] for MVC4 application

I have created a custom role provider for my MVC4 application where I have been successfully able to override CreateRole, GetAllRoles and RoleExists methods and link them to my existing database as follows: namespace Project.Providers { public…
Jay
  • 3,012
  • 14
  • 48
  • 99
2
votes
1 answer

WindowsPrincipal.IsInRole not working in IIS 7/Win Server 2K8, but working on IIS 6/Win Server 2K3

Is there some setting or permission in IIS 7/Win Server 2008 that would cause WindowsPrincipal.IsInRole to always return false, when the same code running in IIS 6/Win Server 2003 works? Here's how I'm calling the method: IPrincipal principal = new…
FishBasketGordo
  • 22,904
  • 4
  • 58
  • 91
2
votes
2 answers

Given the string of the UserName, how can I check if that user IsInRole?

I am attempting to check if a given user has a role before they are fully 'logged in' to the site I am building. Typically I would use the code: User.IsInRole("CustomRole") But in this situation that line always yields "false" - I believe this is…
Ecnalyr
  • 5,792
  • 5
  • 43
  • 89
1
vote
4 answers

How do I find out if an arbitrary DOMAIN\username is in a specific role with C#?

I'm really new to C# so forgive my ignorance. I need to test if a user (DOMAIN\username) is in a particular group, and yes, this includes nested groups. I have found that WindowsPrincipal.IsInRole() works fantastic, when dealing with the current…
Alan M
  • 321
  • 1
  • 3
  • 14
1
vote
1 answer

Why @User.IsInRole not working?

I'm using licensed Devart dotConnect product to connect to a PostgreSql database in my ASP.NET MVC5 project. I have problem with Devart Rolemanager. I installed Dotconnect PostgreSql with folowing this tutorial…
Husni Salax
  • 1,968
  • 1
  • 19
  • 29
1
vote
1 answer

IsInRole - VB Form Load

I've built an application out of Visual Basic with a login screen and a form. The login screen authenticates with Active Directory. After user authentication, the form loads. On form load, I would like to check to see if the authenticated user is…
Lee
  • 13
  • 1
  • 4
1
vote
1 answer

Check IsInRole without requiring the Authorize attribute?

I have created my own Authorize attribute called Authorise... Imports System.Security.Principal Public Class AuthoriseAttribute Inherits…
cw_dev
  • 465
  • 1
  • 12
  • 27
1
2 3