Override User.Identity.Name or Custom IIdentity

Discussion in 'ASP .Net Security' started by Corker, Mar 8, 2010.

  1. Corker

    Corker Guest

    Hi I am using the standard asp.net login control and it is currently working
    well where my users can login with their email address and password.
    I want to modify this so they can enter their email address or membership
    number and password. I have a custom membership provider class where I check
    the login details based on whether an email or number has been entered, again
    this is fine.
    Finally, my problem is that User.Identity.Name is whatever was entered in
    the login box, I want this to always be an email address so can you suggest
    how I can override this value?
    I created a Custom Identity class and tried assigning that in Global.asax
    Application_AuthenticateRequest, but it says it cannot resolve the type
    MyNamespace.CustomIdentity. I'm not sure what to try next.
     
    Corker, Mar 8, 2010
    #1
    1. Advertising

  2. Corker

    Joe Kaplan Guest

    You are close to getting this. The authenticate event on the ASP.NET
    pipeline is the proper event to handle. Basically, you want your custom code
    to run after the various authentication mechanisms like forms auth and
    membership but before authorization takes place. Essentially, you want to be
    the last handler of the Authenticate event. Here, you can swap out the
    principal for whatever you want.

    Your issue sounds like a simple problem related to type references where the
    ..NET framework cannot find your class by the name you tried to use for it.
    This is a more generic issue that you should be able to figure out. Using
    the object browser to find the real name of your type may be helpful.

    --
    Joe Kaplan-MS MVP Directory Services Programming
    Co-author of "The .NET Developer's Guide to Directory Services Programming"
    http://www.directoryprogramming.net
    "Corker" <> wrote in message
    news:...
    > Hi I am using the standard asp.net login control and it is currently
    > working
    > well where my users can login with their email address and password.
    > I want to modify this so they can enter their email address or membership
    > number and password. I have a custom membership provider class where I
    > check
    > the login details based on whether an email or number has been entered,
    > again
    > this is fine.
    > Finally, my problem is that User.Identity.Name is whatever was entered in
    > the login box, I want this to always be an email address so can you
    > suggest
    > how I can override this value?
    > I created a Custom Identity class and tried assigning that in Global.asax
    > Application_AuthenticateRequest, but it says it cannot resolve the type
    > MyNamespace.CustomIdentity. I'm not sure what to try next.
     
    Joe Kaplan, Mar 10, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Mulholland

    Custom IIdentity class - how to set it?

    Tim Mulholland, Feb 20, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,680
    Steven Cheng[MSFT]
    Feb 24, 2004
  2. nalbayo
    Replies:
    2
    Views:
    5,569
    Bruce Barker
    Nov 11, 2005
  3. Spam Catcher

    Custom IIdentity w/ FormsAuthentication

    Spam Catcher, Jan 6, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    6,387
    Spam Catcher
    Jan 7, 2006
  4. Random

    Custom IIdentity object casting

    Random, Jan 25, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    459
    Random
    Jan 25, 2008
  5. Antonio O''Neal

    user.identity.name returns old AD user name

    Antonio O''Neal, Oct 31, 2008, in forum: ASP .Net Security
    Replies:
    5
    Views:
    2,231
    Antonio O''Neal
    Nov 3, 2008
Loading...

Share This Page