REPOST: bug in Forms Authentication

Discussion in 'ASP .Net Security' started by Tim_Mac, Nov 12, 2008.

  1. Tim_Mac

    Tim_Mac Guest

    hi, i tried posting this last month but got no takers, trying again!

    i have a minor problem where some users log in with capital letters
    for their username, which looks bad when displayed on screen and also
    causes discrepancies in some user activity logs maintained in the
    database, e.g. "JOE BLOGGS Login" and "Joe Bloggs Login". in an
    attempt to standardise the username case, i tried to read the correct
    username from the database, this code used to work fine:

    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
    // find the Membership User
    MembershipUser u = Membership.GetUser(this.Login1.UserName);
    if(u == null)
    throw new Exception("Could not locate user account for
    " +
    this.Login1.UserName);

    // use the correct username case (from the aspnetdb database)
    for the
    login cookie
    FormsAuthentication.SetAuthCookie(u.UserName, true);

    }

    but there seems to be a behaviour change since asp.net 3.5, this code
    no longer works as expected, Membership.Username now returns the same
    case as was submitted by the user, so the Username property is
    actually not coming from the database at all. surely this can't be
    'by design'?? can anyone confirm if this is a bug, and/or suggest a
    workaround?
    many thanks
    tim
     
    Tim_Mac, Nov 12, 2008
    #1
    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. Harley
    Replies:
    1
    Views:
    669
    John Saunders
    Nov 25, 2003
  2. Eric
    Replies:
    2
    Views:
    1,527
    Tommy
    Feb 13, 2004
  3. Abhishek Srivastava

    [REPOST] Problem in Windows based Authentication

    Abhishek Srivastava, Feb 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,646
    Ken Schaefer
    Feb 18, 2004
  4. =?Utf-8?B?ZGlnaXRhbFE=?=

    Forms RePost best practice?

    =?Utf-8?B?ZGlnaXRhbFE=?=, Aug 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    429
    =?Utf-8?B?Y2hyaXNjb2xsaW5zb24=?=
    Aug 19, 2004
  5. Eric
    Replies:
    2
    Views:
    595
Loading...

Share This Page