Forcing User.Identity to uppercase

Discussion in 'ASP .Net' started by jobs, Nov 17, 2007.

  1. jobs

    jobs Guest

    Any way to force User.Identity to UpperCase after it's authenitcated?

    Or if not, anybody got a good javascript snippet that would force
    everything you type to upper?

    Thanks.
    jobs, Nov 17, 2007
    #1
    1. Advertising

  2. Howdy,

    1. Forcing User.Name to be upper cased:
    Put follwing code into global.asax file:

    void Application_PostAuthenticateRequest(object sender, EventArgs e)
    {
    HttpContext.Current.User = new MyPrincipal(
    HttpContext.Current.User,
    new MyIdentity(HttpContext.Current.User.Identity));
    }

    public class MyIdentity : System.Security.Principal.IIdentity
    {
    private readonly System.Security.Principal.IIdentity identity;

    public MyIdentity(System.Security.Principal.IIdentity identity)
    {
    this.identity = identity;
    }

    public string AuthenticationType
    {
    get
    {
    return this.identity.AuthenticationType;
    }
    }

    public bool IsAuthenticated
    {
    get
    {
    return this.identity.IsAuthenticated;
    }
    }

    public string Name
    {
    get
    {
    string name = this.identity.Name;
    return name == null ? null : name.ToUpper();
    }
    }
    }

    public class MyPrincipal : System.Security.Principal.IPrincipal
    {
    private readonly System.Security.Principal.IPrincipal principal;
    private readonly System.Security.Principal.IIdentity identity;

    public MyPrincipal(
    System.Security.Principal.IPrincipal principal,
    System.Security.Principal.IIdentity identity)
    {
    this.principal = principal;
    this.identity = identity;
    }

    public System.Security.Principal.IIdentity Identity
    {
    get
    {
    return this.identity;
    }
    }

    public bool IsInRole(string role)
    {
    return this.principal.IsInRole(role);
    }
    }

    2. Forcing inputs to be uppercased:

    <input type="text" style="text-transform: uppercase" />
    <asp:TextBox runat="server" TextMode="SingleLine" ID="txt1"
    Style="text-transform: uppercase" />
    <asp:TextBox runat="server" TextMode="MultiLine" ID="txt2"
    Style="text-transform: uppercase" />

    hope this helps
    --
    Milosz


    "jobs" wrote:

    > Any way to force User.Identity to UpperCase after it's authenitcated?
    >
    > Or if not, anybody got a good javascript snippet that would force
    > everything you type to upper?
    >
    > Thanks.
    >
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Nov 17, 2007
    #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. Giovanni Bassi
    Replies:
    0
    Views:
    628
    Giovanni Bassi
    Oct 20, 2003
  2. nalbayo
    Replies:
    2
    Views:
    5,478
    Bruce Barker
    Nov 11, 2005
  3. Frederick D'hont
    Replies:
    0
    Views:
    298
    Frederick D'hont
    Jul 25, 2005
  4. Replies:
    6
    Views:
    439
  5. Jeffrey
    Replies:
    3
    Views:
    126
    Joe Kaplan
    Sep 27, 2007
Loading...

Share This Page