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

ASP.NET MVC - Set custom IIdentity or IPrincipal

I need to do something fairly simple: in my ASP.NET MVC application, I want to set a custom IIdentity / IPrincipal. Whichever is easier / more suitable. I want to extend the default so that I can call something like User.Identity.Id and…
Razzie
  • 30,834
  • 11
  • 63
  • 78
47
votes
4 answers

What is the idea behind IIdentity and IPrincipal in .NET

So, what is the purpose for existence of both IIdentity and IPrincipal, and not some IIdentityMergedWithPrincipal? When is it not enough to implement both in same class? Also, to understand purpose, I'd like to know where this concept comes…
Aloraman
  • 1,389
  • 1
  • 21
  • 32
31
votes
1 answer

What is Thread.CurrentPrincipal, and what does it do?

What is Thread.CurrentPrincipal used for? How does it help in the Authentication and Authorization of an application? Are there any articles or resources that help explain what it does?
user1844634
  • 1,221
  • 2
  • 17
  • 35
27
votes
2 answers

Set User property for an ApiController in Unit Test

My unit tests for an ApiController uses some helpers methods to instantiate the controller: public static ResourcesController SetupResourcesController(HttpRequestMessage request, IResourceMetadataRepository repo, IUnitOfWorkService…
JTech
  • 3,420
  • 7
  • 44
  • 51
22
votes
4 answers

Custom Identity using MVC5 and OWIN

I trying to add custom properties to the ApplicationUser for a web site using MVC5 and OWIN authentication. I've read https://stackoverflow.com/a/10524305/264607 and I like how it integrates with the base controller for easy access to the new…
BlackICE
  • 8,816
  • 3
  • 53
  • 91
21
votes
1 answer

using custom IPrincipal and IIdentity in MVC3

I create my own IPrincipal and IIdentity implementation as shown below: [ComVisible(true)] [Serializable] public sealed class CustomIdentity : IIdentity { private readonly string _name; private readonly string _email; // and other…
19
votes
3 answers

Implementing a Custom Identity and IPrincipal in MVC

I have a basic MVC 2 beta app where I am trying to implement a custom Identity and Principal classes. I have created my classes that implement the IIdentity and IPrincipal interfaces, instantiated them and then assigned the CustomPrincipal object to…
Jay
  • 2,644
  • 1
  • 30
  • 55
14
votes
2 answers

Asp.net Mvc: Ninject - IPrincipal

I was wondering how I could bind the IPrincipal to HttpContext.Current.User in Asp.net Mvc with Ninject. Friendly greetings, Pickels Edit: Not sure if it matters but I use my own CustomPrincipal class.
Pickels
  • 33,902
  • 26
  • 118
  • 178
13
votes
1 answer

Custom IPrincipal with Forms Authentication in ASP.NET MVC

This should be simple, but I simply cannot figure it out after all my googling. Here's what I want. I have a custom Users table (no roles at the moment) that I'd like to authorize against. For this I'll have to implement a custom Membership Provider…
BFree
  • 102,548
  • 21
  • 159
  • 201
11
votes
2 answers

Is this Custom Principal in Base Controller ASP.NET MVC 3 terribly inefficient?

Despite the fact that I've been on here for a while, this is my first ever question on SO, so please be gentle with me. I'm using ASP.NET MVC 3 and I want to create a custom Principal so I can store a bit more info about the current user than is…
Tom Chantler
  • 14,753
  • 4
  • 48
  • 53
11
votes
3 answers

Why does Resharper think IPrincipal.Identity will never be null?

Resharper 8 running in VS2010 is telling me I can remove a check for principal.Identity != null: I'm assuming this is because there's a NotNull attribute or something lurking in the code for IPrincipal, but it's quite easy to write your own…
Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197
11
votes
1 answer

WebApi ActionFilterAttribute, HttpActionContext access user name (IPrincipal)

I need to access the currently logged in user in my action filter. The identity is set by a DelegatingHandler further up the chain of execution. I can access the current IPrincipal using HttpContext.Current.User. So far I avoided using…
lapsus
  • 2,915
  • 2
  • 32
  • 61
10
votes
2 answers

What's the difference between HttpContext.Current.User and Thread.CurrentPrincipal in asp.net?

Well, I think the title is clear enough.
Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
10
votes
2 answers

Mock IIdentity and IPrincipal

I just wanna ask what would be better approach to supply these objects in my unit tests. In my unit test I am testing CSLA object. CSLA object is internally using one property and one method of ApplicationUser object. ApplicationUser is inherited…
Jaroslav Urban
  • 1,269
  • 3
  • 20
  • 32
10
votes
2 answers

ASP.NET MVC custom IPrincipal injection

I'm working on an application using ASP.NET MVC 1.0 and I'm trying to inject a custom IPrincipal object in to the HttpContext.Current.User object. With a traditional WebForms application I've used the Application_AuthenticateRequest event to do…
Mr Bog
  • 127
  • 1
  • 8
1
2 3
8 9