iidentity

Override HttpContext.Current.User.Identity.Name

三世轮回 提交于 2019-12-25 12:00:24
问题 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 possible to add new properties by adding claims. The two questions I have are: Where to add the claims in the ASP.NET Web Forms pipeline? And Is it possible to override the existing Name property? 回答1: You can implement the PostAuthenticate event in

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

主宰稳场 提交于 2019-12-23 08:30:11
问题 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 implement IIdentity and IPrincipal to store the encrypted password and be able to provide it when performing webservice calls. In the future, we might want to use more of the built-in security of asp.net, so I implement membership and role provider

What is the idea behind IIdentity and IPrincipal in .NET

我们两清 提交于 2019-12-20 08:34:53
问题 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 from: It is originated in .Net There is concept of Identity/Principal as design pattern, which System.Security.Principal implemented in those interfaces It is originated somewhere else and supported for compatibility Therefore, does UserPrincipal from

Moq custom IIdentity

浪子不回头ぞ 提交于 2019-12-13 01:29:12
问题 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 Mock<IPrincipal>(); var identity = new Mock<CustomIdentity>(); user.Setup(ctx => ctx.Identity).Returns(identity.Object); identity.SetupGet(id => id.IsAuthenticated).Returns(true); identity.SetupGet(id => id.LoginName).Returns("test"); // IsAuthenticated is the

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

被刻印的时光 ゝ 提交于 2019-12-10 18:20:51
问题 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 database id for the user. I can make a custom provider or identity by overriding the Application_AuthenticateRequest function. My question is should the database uid for the user go into the principal or the identity? Should the Name property of

What is the idea behind IIdentity and IPrincipal in .NET

女生的网名这么多〃 提交于 2019-12-02 17:25:45
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 from: It is originated in .Net There is concept of Identity/Principal as design pattern, which System.Security.Principal implemented in those interfaces It is originated somewhere else and supported for compatibility Therefore, does UserPrincipal from System.DirectoryServices act similarly to IPrincipal but not implement it by accident or by intention? P

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

烂漫一生 提交于 2019-11-30 15:43:28
问题 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 variables like full name or something else. EDIT : Now i got the following code but if i try to read @((CustomPrincipal)Context.User.Identity).Nachname I'm getting a error that System.Web.Security.FormsIdentity could not be casted to

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

我的未来我决定 提交于 2019-11-30 14:48:13
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 variables like full name or something else. EDIT : Now i got the following code but if i try to read @((CustomPrincipal)Context.User.Identity).Nachname I'm getting a error that System.Web.Security.FormsIdentity could not be casted to CustomPrincipal . Any ideas? public class CustomPrincipal : GenericPrincipal { public CustomPrincipal(IIdentity

using custom IPrincipal and IIdentity in MVC3

牧云@^-^@ 提交于 2019-11-28 04:44:45
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 stuffs public CustomIdentity(string name) { _name = name.Trim(); if(string.IsNullOrWhiteSpace(name)) return; _email = (connect to database and read email and other stuffs); } public string Name { get { return _name; } } public string Email { get { return _email; } } public string AuthenticationType { get { return "CustomIdentity"; } } public bool IsAuthenticated {

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

两盒软妹~` 提交于 2019-11-28 04:35:33
问题 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 upload the application on a real host, it seems all users are in "admin" role! e.g. I create a user that is not in role "admin" , but it can access to all protected pages (that need "admin" role). e.g. Role.IsUserInRole always returns true . Have