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
9
votes
6 answers

How can I make accessing my custom IPrincipal easier in ASP.NET MVC?

I've written a custom principal object which contains a few additional fields (email and userid in addition to the username). In order to access these properties I have to cast the Context.User object as my custom…
Viktor
  • 91
  • 1
  • 1
  • 2
9
votes
3 answers

Wrong Thread.CurrentPrincipal in async WCF end-method

I have a WCF service which has its Thread.CurrentPrincipal set in the ServiceConfiguration.ClaimsAuthorizationManager. When I implement the service asynchronously like this: public IAsyncResult BeginMethod1(AsyncCallback callback, object state) …
MvdD
  • 22,082
  • 8
  • 65
  • 93
9
votes
1 answer

Do I really need to call Dispose() on every Principal?

I'm doing some Active Directory work with .NET's System.DirectoryServices.AccountManagement namespace. I noticed that Principal implements IDisposable, which causes sort of a headache since everything in that namespace inherits Principal. E.g.…
Hank
  • 8,289
  • 12
  • 47
  • 57
8
votes
4 answers

asp.net extending IPrincipal

I would like to extend IPrincipal in asp.net to allow me to get the usertype that I will define. I would like to make it possible to do this in a controller string type = User.UserType then in my extension method i will have a method like public…
twal
  • 6,999
  • 17
  • 48
  • 58
8
votes
5 answers

SerializationException on 'CustomIdentity' when user is denied in ASP.NET

I try to implement ASP.NET Authentication and Authorization on top of our existing database. We have a website calling a webservice to fetch its data. To use the webservice, i need to provide the username and password. Knowing that, I decided to…
8
votes
5 answers

Obtaining the current Principal outside of the Web tier

I have the following ntier app: MVC > Services > Repository > Domain. I am using Forms authentication. Is it safe to use Thread.CurrentPrincipal outside of my MVC layer to get the currently logged in user of my application or should I be using…
7
votes
1 answer

MVC3 + Ninject: What is the proper way to inject the User IPrincipal?

I have seen the following two example for injecting the User IPrincipal: Method 1: kernel.Bind() .ToMethod(context => context.Kernel.Get().HttpContext.User) .InRequestScope(); Method 2: kernel.Bind() …
Shawn
  • 1,871
  • 2
  • 21
  • 36
7
votes
2 answers

UserPrincipal.IsMemberOf is returning false

I am trying to validate the user is in the "TestGroup" group or not. The user is part of the "TestGroup" group, even i am getting the retval = false @line(retVal = user.IsMemberOf(groupPrincipal);), and in event viewer it is showing msg as "The user…
user190881
  • 169
  • 2
  • 11
6
votes
1 answer

IPrincipal.IsInRole() only works when I truncate the role names - why?

I have an application that relies heavily on authorization of users. Within it, I am using IPrincipal.IsInRole() to check whether users are in the correct groups: IPrincipal principal = Thread.CurrentPrincipal; bool inRole =…
adrianbanks
  • 81,306
  • 22
  • 176
  • 206
6
votes
3 answers

Inject IPrincipal with SignalR

I am trying to inject IPrincipal into my SignalR hub constructors. I already saw and tried the solution from "Selective IPrincipal Injection via StructureMap with SignalR", but unfortunately that doesn't seem to work anymore for SignalR 2.x. In my…
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202
6
votes
1 answer

How do you use IPrincipal and IIdentity in the portable class libraries?

With WIF (Windows Identity Foundation) 4.5, Microsoft created the WindowsPrincipal class, which is a type of ClaimsPrincipal. Of course, these classes aren't portable, but the interfaces behind them are (IPrincipal). The same can be said of the…
michael
  • 14,844
  • 28
  • 89
  • 177
6
votes
3 answers

linqpad and custom IPrincipal serializable

I'm using LINQPad to test code (what a great product, I must say) but now I'm encountering an exception when I try to set the Thread.CurrentPrincipal to a custom IPrincipal that is marked with the SerializableAttribute following a sample that…
mCasamento
  • 1,413
  • 1
  • 11
  • 21
5
votes
1 answer

Implementing IPrincipal and IIdentity in MVC with use of custom membership and role provider

I'm stuck with the implementation of a custom iprincpal and iidentity object. I spend a day now for searching how to implement these right and extend it with more informations. I want to extend the Information @Context.User.Identity.Name with custom…
float
  • 1,265
  • 5
  • 22
  • 38
5
votes
1 answer

Cannot Deserialize ClaimsPrincipal

Given I create a claims identity and subsequently a principal. Then I serialize the principal. Inspecting the json string I can confirm that the "Role" claim is there as well as the identity. Deserializing it back results in an object with empty…
Cristian E.
  • 3,116
  • 7
  • 31
  • 61
5
votes
0 answers

Why is Thread.CurrentPrincipal.Identity.IsAuthenticated false when creating an instance using Simple Injector

Basically I am trying to get the current set of claims for an authenticated user (via bearer token) currently accessing a Web Api; by injecting the current principal into a helper class, which is then injected into class that is injected into an…
teatime
  • 341
  • 1
  • 3
  • 10
1
2
3
8 9