Questions tagged [iidentity]

In .NET, IIdentity interface defines basic functionality of an identity object

Defines the basic functionality of an identity object. An identity object represents the user on whose behalf the code is running. This interface is implemented by the GenericIdentity and WindowsIdentity classes.

36 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
28
votes
3 answers

Set Identity of Thread

In C#, how do I set the Identity of a Thread? For example, if I have Thread MyThread, which is already started, can I change MyThread's Identity? Or is this not possible?
Duncan
  • 10,218
  • 14
  • 64
  • 96
27
votes
7 answers

HttpContext.Current.User.Identity.Name is always string.Empty

Hi I use a custom MembershipProvider. I want to know the current username during an application scenario, but when I try accessing HttpContext.Current.User.Identity.Name it always returns string.Empty. if (Membership.ValidateUser(tbUsername.Text,…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
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
1 answer

Implementing IIdentity, what is AuthenticationType?

I have a custom class (with properties like UserID, UserName, UserEmail, etc) implementing IIdentity. I login through custom logic, which reads from sql. What should IIdentity's AuthenticationType return?
TDaver
  • 7,164
  • 5
  • 47
  • 94
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…
6
votes
3 answers

Unity equivalent for Ninject's Bind.ToMethod of IPrincipal,IIdentity

I'm trying to replicate the following Ninject syntax in Unity, but not having any luck: Bind().ToMethod(c => HttpContext.Current.User.Identity); I'm thinking it ought to look something like: IUnityContainer…
Alfred
  • 800
  • 8
  • 16
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
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
2 answers

Override the IIdentity property of User

I have developed a simple IIdentity and IPrincipal for my MVC project and I would like to override the User and User.Identity to return the value with the right type Here is my custom Identity: public class MyIdentity : IIdentity { public…
JuChom
  • 5,717
  • 5
  • 45
  • 78
4
votes
1 answer

What set's the User.Identity.Name and User.Identity.IsAuthenticated?

I want to know what set's the user identity name and change isAuthenticatedto true. Why is User.Identity.Name an empty string and User.Identity.IsAuthenticated false after SignInManager.PasswordSignInAsync has returned Success. // POST:…
radbyx
  • 9,352
  • 21
  • 84
  • 127
1
2 3