Questions tagged [iprincipal]

The System.Security.Principal.IPrincipal interface defines the basic functionality of a security object. It is most commonly used by applications written for the Microsoft.NET framework.

The System.Security.Principal.IPrincipal interface defines the basic functionality of a security object. This object represents the security context of the user on whose behalf the code is running, including that user's identity (IIdentity) and any roles to which they belong.

129 questions
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
3 answers

WindowsPrincipal.IsInRole() not returning the expected result

So here's my current code: List rowGroups = GetFileGroups((int)row.Cells["document_security_type"].Value); bool found = false; System.Security.Principal.WindowsPrincipal p = new…
Miles
  • 5,646
  • 18
  • 62
  • 86
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
1 answer

Winforms main UI thread principal reverting to previous

I am working on a Winforms app that uses the CSLA framework with custom authentication (i.e. The middle tier/server manages authentication) and am in the process of implementing a Session Timeout feature. The problem I am having is a weird issue…
oatsoda
  • 2,088
  • 2
  • 26
  • 49
3
votes
1 answer

How to create custom iPrincipal in MVC 4, WinAPI

I'm experiencing a situation that I have find nowhere in other articles. I'm designing a RESTful server to be consumed by an mobile app. In this case, username and password are part of header in app call, there is no logon screen. The following code…
Marco Castro
  • 111
  • 7
3
votes
1 answer

How to do ASP.NET Web API integration tests with custom authentication and in-memory hosting

A similar question has been answered here but the answer doesn't seem to work in my case. I want to test the authentication/authorization process in my Web Api which is using a JWT authentication. My authentication is handled through a custom…
2
votes
2 answers

Authenticate against ActiveDirectory

I did a little Googling and I came accross this promising code System.DirectoryServices.AccountManagement.PrincipalContext pc = new System.DirectoryServices.AccountManagement.PrincipalContext(ContextType.Domain, "YOURDOMAIN") // validate the…
Cocoa Dev
  • 9,361
  • 31
  • 109
  • 177
2
votes
1 answer

Current User is LocalSystem Check?

It is easy enough to determine if the user running my C# .NET 4.0 console app is a member of the local Administrators group. I am also trying to determine if it is running under LocalSystem. What is the best way to do that?
Snowy
  • 5,942
  • 19
  • 65
  • 119
2
votes
1 answer

What is the best way to cache a custom IPrincipal for a asp.net mvc website?

I have implemented a custom IPrincipal that I set in protected void Application_PostAuthenticateRequest(Object sender, EventArgs args) by doing Context.User = GetCustomPrincipal(User.Identity); Thread.CurrentPrincipal = Context.User; But my…
lahsrah
  • 9,013
  • 5
  • 37
  • 67
2
votes
2 answers

MVC Authorization Role and IPrincipal - how does it work?

I've managed to successfully implement a custom MembershipProvider for my MVC2 application. I have my own User table as well as Role table. My problem right now is that when I put in the [Authorize(Roles="blah")] attribute, it doesn't work. I've…
Ray
  • 41
  • 4
2
votes
3 answers

ASP.NET Core Identity - How to add new claims after initial login

I am trying to add new claims to the Identity after the initial login based on certain data that is queried from database. The new claims that I am adding not persisting for subsequent requests. This is how i'm setting/Adding claims in ASP.NET…
2
votes
2 answers

Impersonating a user in ASP.NET MVC for testing

Is there an easy way to substitute current User object (the one inside controller) with IPrincipal having properties of another user? I'm thinking about environment that users Windows authentication and AD groups, so it's desirable to replicate all…
2
votes
2 answers

Retrieving User Name from Active Directory

I am trying to retrieve the User Name from Active Directory. I have found this piece of code to try however, it does not recognize the User portion of User.Identity.Name. I have looked to see if I need to add another reference or assembly however I…
Ethel Patrick
  • 885
  • 7
  • 18
  • 38
2
votes
2 answers

Custom ASP.Net Principle - Unable to cast object of type 'System.Security.Principal.GenericPrincipal' to type 'Business.ICustomPrincipal'

I have implemented a custom Principle for ASP.Net identity, however when I try to get my custom principle from HttpContext.Current.User I receive the following exception: Unable to cast object of type 'System.Security.Principal.GenericPrincipal' to…
Simon
  • 6,062
  • 13
  • 60
  • 97
2
votes
1 answer

Materializing Custom Principal With AspNet.Security.OpenIdConnect.Server (ASP.NET vNext)

I am using Visual Studio 2015 Enterprise and ASP.NET vNext Beta8 to build an endpoint that both issues and consumes JWT tokens as described in detail here. I am at the phase in my project where I want to allow the JWT bearer authentication to…
42vogons
  • 683
  • 7
  • 19
1 2 3
8 9