Re: creating custom HttpContext.Current.User.Identity

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 02/19/04


Date: Wed, 18 Feb 2004 23:18:32 -0600

I think you can use the same IPrincipal that Forms auth uses, but if for
some reason you can't, you can easily use the GenericPrincipal class with
your custom IIdentity implementation. Its constructor takes any type
implementing IIdentity.

It is also totally reasonable to derive from GenericPrincipal or
GenericIdentity (or most of the framework IIdentity or IPrincipal
implementations for that matter) if you want.

Joe K.

"dSchwartz" <schwartz@cableone.net> wrote in message
news:4ae1ece2.0402181442.70de4e41@posting.google.com...
> I've started getting into using forms authentication for asp.net apps
> with c#. From what i understand so far (limited) I like the way
> things work! I've got an application working right now where an email
> address and password is checked from a database and I can check the
> authenticated user's email address with
> HttpContext.Current.User.Identity.Name. This all works fine!
>
> I want to be able to do:
> HttpContext.Current.User.(customIdentity?).EmailAddress
> HttpContext.Current.User.(customIdentity?).UserID
> HttpContext.Current.User.(customIdentity?).NickName
>
> I'm just a bit confused about what i have to do after reading many
> different posts and articles about this. It seems to me like i should
> only have to create a custom class that extends IIdentity, but then to
> use that don't i have to create a custom class that extends IPrincipal
> also? and then it also seems i need a custom
> FormsAuthenticationTicket class also???
>
> I'm just looking for the simplest way to do this, which classes do i
> have to create custom for this action?
>
> Thanks for your time!



Relevant Pages

  • Re: friendly error messages for usernameForCertificateSecurity
    ... message security is valid is it put into the OperationState for the current ... method in my custom assertion's service input filter and then throw an error ... identity = new GenericIdentity(string.Empty); ... // new method a custom token manager must implement ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Interface question
    ... My understanding of IPrincipal and IIdentity isn't the best, ... without the IPrincipal inheritance. ... Windows and Forms based authentication both use the interfaces, ... Though we didn't use a custom principal class we could have and it might ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Interface question
    ... My understanding of IPrincipal and IIdentity isn't the best, ... without the IPrincipal inheritance. ... Windows and Forms based authentication both use the interfaces, ... If you didn't use a custom principal class, I assume you don't store your ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Interface question
    ... My understanding of IPrincipal and IIdentity isn't the best, ... Windows and Forms based authentication both use the interfaces, ... When you talk about users and roles stored in a database, ... If you didn't use a custom principal class, I assume you don't store your ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Interface question
    ... My understanding of IPrincipal and IIdentity isn't the best, ... Windows and Forms based authentication both use the interfaces, ... When you talk about users and roles stored in a database, ... If you didn't use a custom principal class, I assume you don't store your ...
    (microsoft.public.dotnet.framework.aspnet)