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
4
votes
1 answer

Should User class implement IPrincipal and IIdentity

I'm building my own token based authentication for asp.net web api 2 and I have a question about the user class. Currently my user class implements IPrincipal and IIdentity, but I don't know what is the best practice. Would you divide IPrincipal and…
BendEg
  • 20,098
  • 17
  • 57
  • 131
4
votes
2 answers

RoleProvider dosn't work with custom IIdentity and IPrincipal on server

I'm using a custom IIdentity and IPrincipal in my ASP.NET MVC application via EF 4.3 as expalined here (and follow accepted answer's solution). Also, I have a custom RoleProvider. In local (using IIS Express), it works currectly. But now, when I…
amiry jd
  • 27,021
  • 30
  • 116
  • 215
3
votes
2 answers

Strongly Typed @User.Identity

I customize IIdentity and IPrincipal adding a few more properties in IIdentity. You can obtain a strongly typed instance @User.Identity for my custom class? Without having to make conversions in cast. I thought of something like razor customize the…
ridermansb
  • 10,779
  • 24
  • 115
  • 226
3
votes
1 answer

Store user id in Principal or Identity? ASP.Net/OpenID

I have an ASP.Net MVC web application using forms authentication. I am using OpenID for authentication. At the moment the moment I'm storing the openID url inside the Name of the standard GenericIdentity. I would also like to have easy access to the…
tpower
  • 56,100
  • 19
  • 68
  • 100
3
votes
1 answer

MVC2 :: How do I *USE* a Custom IIdentity Class?

I am trying to store a whole truckload of information about a user from a webservice. As this is information about the currently authenticated user, I thought it would make sense to store that information in a custom IIdentity implementation. The…
Scott Baker
  • 10,013
  • 17
  • 56
  • 102
2
votes
2 answers

Custom User.Identity to add property

I customize RoleProvider and MembershipProvider classes I would like to add one more property in my @User.Identity, as do so? example: @User.Identity.About => .About not exist yet I thought I'd customize IIdentity but do not know where to start.
ridermansb
  • 10,779
  • 24
  • 115
  • 226
2
votes
0 answers

Moving to use Claims Identity in .Net Core

In our current system (.net 4.5) to handle user authentication throughout the app we have created our own IIdentity and IPrincipal objects. So on every request we decrypt an attribute in the cookie (stored at login) and using this we check the cache…
Gaz
  • 1,249
  • 3
  • 19
  • 37
2
votes
1 answer

Extension of IIdentity

I'm trying to use the exention method for IIdentity Here is my class: public static class MyIdentity { public static string FullName(this IIdentity identity) { return "John Doe"; } } and I'm trying to use it on my view like…
Anas
  • 5,622
  • 5
  • 39
  • 71
1
vote
1 answer

User.Identity.GetUserId() always returns null in controller action

I needed to use current logged in user id in controller. It always returns null. I am already logged in. Here's my code. if (string.IsNullOrEmpty(userId)) userId = User.Identity.GetUserId(); I tried adding the reference using…
1
vote
1 answer

Get Owin IIdentity from IHttpHandler

Accepted answer note: Although I have appreciated the help of creating my own OwinMiddleware to send images after doing some checks instead of IHttpModule, that doesn't solve the issue entirely. The thing is I have added an Authorization header to…
Azadrum
  • 756
  • 6
  • 23
1
vote
2 answers

Moq custom IIdentity

I created a custom RoleProvider (standard webforms, no mvc) and I would like to test it. The provider itself integrates with a custom implementation of IIdentity (with some added properties). I have this at the moment: var user = new…
Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61
0
votes
1 answer

Shopping Cart in IIdentity IPrincipal

I am delevoping an order management system for my customers. And in this system, I decided to use IPrincipal instead of IIdentity. I have been thinking for a long time about where I should store customer's cart data. Finally I decided to store in…
senjizu
  • 103
  • 12
0
votes
1 answer

Thread.CurrentPrincipal is Reset/ClaimsPrincipal Lost when retrieving from ClaimsPrincipal.Current

I am have a WinForms App running .Net 4.5.2. When logging in, I create a ClaimsPrincipal with a bunch of claims. I save to the Thread.CurrentPrincipal. In the same logging-in process, the ClaimsPrincipal works fine. After the application…
Chris
  • 1,690
  • 2
  • 17
  • 24
0
votes
1 answer

Override HttpContext.Current.User.Identity.Name

I am trying to hook into the Web Forms ASP.NET pipeline and extend the HttpContext.Current.User.Identity in such a way that the Name property returns a custom implementation. One possible approach which I have found in another answer that it is…
user2609980
  • 10,264
  • 15
  • 74
  • 143
0
votes
1 answer

Get custom "IIdentity and IPrincipal" client from WCF Service

I have a custom IIdentity called MyIdentity, and custom IIprincipal called MyPrincipal. These classes are used in three different projects: ASP.NET MVC ASP.NET WebForms Windows Forms These three projects get information from a WCF Service. It is…
JaimeCamargo
  • 353
  • 1
  • 3
  • 14