Forcing User.Identity to uppercase

J

jobs

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.
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top