Using the Ibuyspy framework once a user logs would like to hold onto the UserID behind the sceens. Then whenever the user adds a record I would like to store the userID rather than the users email address. I believe currently this is store in Context.User.Identity.Name
Using VB.Net how could I or what would be the best method to hang onto both the username email and userid. I don't want to use session variables. In advance thanks for you advice and help.
What you want is a unique addressable id... something like the userID. But the user's e-mail address is also unique (or you make the unique). After that... you can make personal modules... and you address them by the users mail address. Hope this helps, ShadowDanser
Please remember to 'Mark as Answer' if this post answered your question!
What I really would like to do is exend the Context.User.Identity.MYFIELD currently the value that is driving is Context.User.Identity.Name but I would like to add my own personal ID and hang onto it the same way Name is being hung onto. How could I extend
this?
You COULD just put the UserID in the UserName field. After all, to you, that IS the name you are most interested in, right? It's meant to hold the user's identifying information. Use it as you see fit.
Because it is far faster to look up an entry based on a number than it is on text. That's actually beside the point, though. I took the question to be how to extend Context.User.Identity to include the ID number as well. I say just store the ID number in there,
and look up the other information if you need. Extending it would be useful in that you could avoid looking up the user info each trip to the server to support "Welcome Joe" on every screen. As an alternative, you could store the ID AND the name in the name
field. Just delimit them with something that's not allowed to be in a user name. For instance, my "name" could be "42|Mel Grubb". A simple call to Split, and you have all your information handy. Then you don't have to change the underlying objects at all.
Mel, You bring up a couple of very good points which could work, however is there a way to exented the context.User.Identity to add another column which will hold an addtional value.-tiny
I did it this way. Not sure if it's the "correct" way but it works for me. In global.asax code behind, in the Application.AuthenticateRequest method, I just added any new properties I wanted to track for the user in the Context.Items collection. For example,
after I know the user is authenticated, I read in the user record, then set a few things such as: Context.Items.Add("UserId", CStr(dr("UserId"))) Then, later in my site I access using HttpContext.Current.Items("UserId") Hope this helps. If anyone figures out
a better way to do this or has any comments, please post.
TinyPond said: You bring up a couple of very good points which could work, however is there a way to exented the context.User.Identity to add another column which will hold an addtional value.-tiny You just extend what Mel said by just pipe delimiting
everything you want. For example, UserName|UserID|SomeOtherValue Then you can just use .Split to get the values out: string myValues = Context.User.Identity.Name; string[] arrayValues = myValues.Split('|'); string userName = arrayValues[0]; string userID =
arrayValues[1]; string someOtherValue = arrayValues[2]; I just typed in the above code but you should get the idea. HTHs, Brian
TinyPond
Member
739 Points
228 Posts
Extending Context.User.Identity.Name to add USERID
Aug 16, 2002 04:58 AM|LINK
ShadowDanser
Participant
1581 Points
437 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 16, 2002 08:46 AM|LINK
TinyPond
Member
739 Points
228 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 16, 2002 04:48 PM|LINK
MelGrubb
Member
22 Points
3 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 19, 2002 01:49 PM|LINK
JoergS
Member
50 Points
10 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 19, 2002 06:35 PM|LINK
Joerg
DarylDart
Member
5 Points
1 Post
Re: Extending Context.User.Identity.Name to add USERID
Aug 20, 2002 10:21 AM|LINK
MelGrubb
Member
22 Points
3 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 20, 2002 10:55 AM|LINK
TinyPond
Member
739 Points
228 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 20, 2002 01:03 PM|LINK
redwards1966
Member
160 Points
32 Posts
Re: Extending Context.User.Identity.Name to add USERID
Aug 28, 2002 04:17 PM|LINK
DNNStuff Admin
www.dnnstuff.com
Home of Aggregator (Tabbed Modules) and free module SQLView
Brian Bilbro
Member
115 Points
23 Posts
ASPInsiders
Re: Extending Context.User.Identity.Name to add USERID
Aug 28, 2002 10:22 PM|LINK