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
1
vote
0 answers

Verify Group based permissions

I have ASP.NET MVC3 application. We have added Window Based authentication. ON some controller we have to do further authorization. For example, I want preference page to be view-able for "ABCGroup" I tried to use: IsInRole("ABCGroup") method. It…
Vivek
  • 11
  • 2
0
votes
0 answers

Working around "The trust relationship between the primary domain and the trusted domain failed" when connectivity is lost with IsInRole()?

We had an issue where network connectivity was lost between trusted domains. Even by just using the sample code (with slight updates) on the documentation for WindowsPrincipal.IsInRole…
jmlumpkin
  • 922
  • 2
  • 14
  • 34
0
votes
2 answers

User.IsInRole("Admin") returning always false in _Layout.cshtml

In layout.cshtml I am checking whether the current user is an admin or not. If so, then a different menu is shown. However, it is always returning false, even when logging in with an admin. I am using the code below: @if…
Rick Astley
  • 125
  • 1
  • 11
0
votes
1 answer

How to change and apply role for current user in ASP.NET MVC 5

I will first introduce the steps that led me to role authorization problems. First I add 2 roles in my construstor in HomeController.cs public HomeController() { _db = new ApplicationDbContext(); _roleManager = new…
0
votes
1 answer

My.user.IsInRole always returning false

Currently, I'm working in one migration request, where we need to change the framework from 3.5 to 4.6.2. Here the problem is after changing the framework below method is not showing result as expected. My.User.IsInRole() is always returning…
0
votes
1 answer

My.User.IsInRole() is not working after migrating to 4.6.2 framework in vb.net

Currently i'm working in one migration request, where we need to change the framework from 3.5 to 4.6.2. Here the problem is after changing the framework below method is not showing result as expected. My.User.IsInRole() is returning null. Could…
0
votes
0 answers

mvc signalr chat - identity user role as prefix

so I'm having troubles using MVC Identity user roles as prefixes in my signalr chat. This is jQuery inside a script tag in the view. the view: var admin = "@User.IsInRole("Administrator");" // Add the message to the page. if (admin) { …
CAMELYON
  • 31
  • 1
  • 1
  • 10
0
votes
1 answer

Verify logged in user against exchange distribution list or AD groups in c#

I am trying to verify whether the logged in user exists in a AD group or distribution list. I tried to use WindowsIdentity but that does not give me proper results. If I add a user to the DL and then check whether the user is in the DL, it gives me…
Ashish
  • 2,544
  • 6
  • 37
  • 53
0
votes
2 answers

The User.IsInRole working for Admin but false for other users

In my _Layout.chtml, I want to show menu on the navbar based on the user role. To make it short, I have "Admin" and "User" role. Here is my code in the _Layout.html
Waller
  • 433
  • 1
  • 6
  • 20
0
votes
1 answer

filtering a recordlist User.IsInRole MVC

I have 16 different roles and I'm trying to filter a list according to a users role. I was hoping there was a way to filter this using LINQ but I'm not sure of the best approach for this. [HttpPost] public ActionResult Login(int? Group, int?…
brachen33
  • 117
  • 2
  • 10
0
votes
0 answers

User.IsInRole() not working in MVC 4

I know this question is asked many times. I tried all solutions but not getting it worked. I a using MVC4 and using forms authentication. I am not using membership but want to store roles in Forms Authentication. I am using below code to achieve my…
Rahul Jha
  • 874
  • 1
  • 11
  • 28
0
votes
1 answer

How to use IsInRole from ASP.NET Membership in the Library dll

Most Real world web applications have at least one dll library behind them. If we use the ASP.NET membership provider, how can we call the Roles.IsInRole method in the dll? The possibility of referencing HttpContext is not good. Because, we have a…
ojeke
  • 1
  • 1
0
votes
1 answer

How to override IsInRole method in MVC 4 Custom Membership?

I'm very new to MVC. I'm doing a Custom Membership asp.net MVC4. Above are the Table & data i have created. I try to override isinrole method but its not working.Below is the sample code & i don't know where to edit it. public override bool…
Yobi Woo
  • 49
  • 7
0
votes
1 answer

How not to use a magic string with IsInRole in Silverlight RIA?

I have extended the UserBase class in System.ServiceModel.DomainServices.Server.ApplicationServices in my Silverlight RIA, and yes people still use Silverlight, and I was wondering what the best practice would be regarding…
-1
votes
2 answers

My.User.IsInRole is returning false

I was trying to migrate a vb.net application from .net framework 2.0(Visual studio 2008) to .net framework 4.7.0 (Visual studio 2017). Here the problem is, IsInRole method is working fine to check whether the current user is part of roles in visual…