Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Forcing User.Identity to uppercase

Reply
Thread Tools

Forcing User.Identity to uppercase

 
 
jobs
Guest
Posts: n/a
 
      11-17-2007
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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      11-17-2007
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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
uppercase ASP .Net 1 02-20-2006 05:23 AM
turn uppercase on in controls Beffmans ASP .Net 1 08-02-2005 01:59 PM
Converting string to uppercase using Perl5Substitution Sudeep Batra - Bond 007 Java 2 04-08-2004 10:52 AM
Converting to uppercase using Perl5Substitution Sudeep Batra - Bond 007 Java 1 04-07-2004 12:49 AM
converting asp:textbox to uppercase Ruby ASP .Net 1 07-31-2003 04:51 PM



Advertisments