Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Identity in ASP.Net 2.0

Status
Not open for further replies.

modika11

Programmer
Jan 31, 2008
20
Hi All,

I have created a custom membership provider which now works nicely in my app. But what i want to do now is extend the identity object to include a couple of extra properties such as userID and fullName so that i can grab it out of the current context without having to go back to the database. I know this was possible in 1.1 (and i am sure not much has changed) but i cant seem to find much documentation on it so am a little unsure if this is the best way to go.

Any suggestions?

Thanks,

Rob
 
David Hayden has some articles related to this topic you would need to use your custom Identity object and cast the IIdentity from the context to your type
Code:
public class MyCustomIdentity : IIdentity
{
   public string FullName { get; set; }
   public Int SomeNumber { get; set; }
}
when accessing the identity you will need to cast it
Code:
MyCustomIdentity identity = (MyCustomIdentity)HttpContext.Current.User.Identity;
string fullName = identity.FullName;
int number = identity.SomeNumber;

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
This reminds me of that old Jerry O'Donnell show "My Secret Identity" from the late 80's/early 90's.
 
Thanks for your response Jason. tperri, i must have missed that one :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top