Extending Context.User.Identity.Name to add USERIDhttp://forums.asp.net/t/32497.aspx/1?Extending+Context+User+Identity+Name+to+add+USERIDMon, 29 Sep 2008 02:22:03 -04003249732497http://forums.asp.net/p/32497/32497.aspx/1?Extending+Context+User+Identity+Name+to+add+USERIDExtending Context.User.Identity.Name to add USERID 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. 2002-08-16T04:58:58-04:0032568http://forums.asp.net/p/32497/32568.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID 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 2002-08-16T08:46:43-04:0032832http://forums.asp.net/p/32497/32832.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID 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? 2002-08-16T16:48:37-04:0033911http://forums.asp.net/p/32497/33911.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID 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. 2002-08-19T13:49:09-04:0034154http://forums.asp.net/p/32497/34154.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID I don't understand why you want to do that. If you have a unique ID, that should be enough...why to use to unique id's for one entry? 2002-08-19T18:35:02-04:0034543http://forums.asp.net/p/32497/34543.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID What about using Global.asax to set a Session_Start variable and read it anywhere throughout the app eg. strVar = Session(CStr(&quot;UserID&quot;)) 2002-08-20T10:21:51-04:0034549http://forums.asp.net/p/32497/34549.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID 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 &quot;Welcome Joe&quot; 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 &quot;name&quot; could be &quot;42|Mel Grubb&quot;. A simple call to Split, and you have all your information handy. Then you don't have to change the underlying objects at all. 2002-08-20T10:55:46-04:0034626http://forums.asp.net/p/32497/34626.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID 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 2002-08-20T13:03:21-04:0039895http://forums.asp.net/p/32497/39895.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID I did it this way. Not sure if it's the &quot;correct&quot; 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(&quot;UserId&quot;, CStr(dr(&quot;UserId&quot;))) Then, later in my site I access using HttpContext.Current.Items(&quot;UserId&quot;) Hope this helps. If anyone figures out a better way to do this or has any comments, please post. 2002-08-28T16:17:29-04:0040207http://forums.asp.net/p/32497/40207.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID TinyPond said: <i>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> 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 2002-08-28T22:22:58-04:0042941http://forums.asp.net/p/32497/42941.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID OK - I'm done ... I used the recommendations in this thread to make changes that allow me to simply refer to the user id, name, or email throughout my application using: UserInfo.ID(context.user.identity.name) or UserInfo.Name(context.user.identity.name) or UserInfo.Email(context.user.identity.name) I had the same desire/need to use more than an email to refer to a user, i.e., I wanted access to the User ID, Email, and Name throughout my application (e.g., display name instead of email in banner, use id as foriegn key in db tables rather than email, use email for notifications, etc.) I initially used a cookie for user name that I set in the signin.ascx.vb file but wanted to use something in the context.user.identity session properties - I want to limit use of cookies for my mobile users and I feel that the id, name, and email are related and should 'travel' together. My approach (based in large part on the guidance of other posts - thanks!): 1) In the security.vb component, I added the following parameter to the usersDB.login method: Dim parameterUserID As New SqlParameter(&quot;@UserID&quot;, SqlDbType.Int) parameterUserID.Direction = ParameterDirection.Output myCommand.Parameters.Add(parameterUserID) 2) I modified the UserLogin sproc to select and return the UserID from the users table (I added the '@UserID integer output' param in at the end of the param list and '@UserID = UserID' in the select list) 3) In the security.vb component (at the bottom right below the UsersDB.login method), I added a new abstract class with only shared methods to bundle the logic to build and parse a UserInfo string that contains the user id, name, and email delimited by pipes (as suggested by Brian). This class allows me to access any userInfo field easily, e.g., UserInfo.Name(context.user.identity.name) or UserInfo.Email(context.user.identity.name) Public Class UserInfo Public Shared Function InfoString(ByVal ID As String, ByVal Name As String, ByVal Email As String) As String Return ID &#43; &quot;|&quot; &#43; Name &#43; &quot;|&quot; &#43; Email End Function Public Shared Function ID(ByVal UserInfo As String) As String Dim items() As String items = UserInfo.Split(&quot;|&quot;) Return items(0) End Function Public Shared Function Name(ByVal UserInfo As String) As String Dim items() As String items = UserInfo.Split(&quot;|&quot;) Return items(1) End Function Public Shared Function Email(ByVal UserInfo As String) As String Dim items() As String items = UserInfo.Split(&quot;|&quot;) Return items(2) End Function End Class 4) In the security.vb component, I added the following method call to the new UserInfo.InfoString method at the end of the usersDB.login method to return the UserInfo string: Return UserInfo.InfoString(parameterUserID.Value, CStr(parameterUserName.Value).Trim(), CStr(parameterEmail.Value).Trim()) 5) In Signin.ascx.vb, I changed the references to userID to userInfo to more accurately reflect reality and I changed the userName parameter in the setauthcookie from email.text to the userInfo field returned by usersDB.login: FormsAuthentication.SetAuthCookie(userInfo, RememberCheckbox.Checked) 6) Now you can change references in other IBS files/modules from context.user.identity.name (or just user.identity.name) to UserInfo.Email(context.user.identity.name). I just did a &quot;search in files&quot; and replaced each occurance (about 12 of them). At a minimum, change the two occurances in the global.asax file. ***** DONE! Now I can simply refer to UserInfo.ID(context.user.identity.name) or UserInfo.Name(context.user.identity.name) or UserInfo.Email(context.user.identity.name) anywhere. For example, in the DesktopPortalBanner, I was simply able to change the welcome message text to: WelcomeMessage.Text = &quot;Welcome &quot; &amp; UserInfo.Name(Context.User.Identity.Name) &amp; &quot;! &lt;&quot; &amp; &quot;span class=Accent&quot; &amp; &quot;&gt;|&lt;&quot; &amp; &quot;/span&quot; &amp; &quot;&gt;&quot; I'm new to ASP and ASP.NET, but I think this is very clean. Thoughts? Critique? 2002-09-03T02:06:48-04:0047527http://forums.asp.net/p/32497/47527.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID One more change - I missed this at first (thanks to Anthony Fisher) ... In the Register.aspx.vb file, you also need to make the following quick changes (change lines have an '***** after them: Private Sub RegisterBtn_Click(ByVal sender As Object, ByVal E As EventArgs) Handles RegisterBtn.Click ' Only attempt a login if all form fields on the page are valid If Page.IsValid = True Then ' Add New User to Portal User Database Dim accountSystem As New ASPNetPortal3.UsersDB() ' ibschange - add user id/name to user.identity - set userName in AuthCookie to UserInfo ***** ' 1. dim userid and set to new user id returned by AddUser ***** ' 2. in IF statement, check userId vs. accountSystem.AddUser(Name.Text, Email.Text, Password.Text) ***** ' 3. change email.text to userInfo.InfoString(...) in SetAuthCookie ***** Dim UserID As Integer '***** UserID = accountSystem.AddUser(Name.Text, Email.Text, Password.Text) '***** If UserID Then '***** ' Set the user's authentication name to the userId '***** FormsAuthentication.SetAuthCookie(UserInfo.InfoString(UserID, Name.Text, Email.Text), False) '***** ' Redirect browser back to home page' Response.Redirect(&quot;~/DesktopDefault.aspx&quot;) Else Message.Text = &quot;Registration Failed! &lt;&quot; &amp; &quot;u&quot; &amp; &quot;&gt;&quot; &amp; Email.Text &amp; &quot;&lt;&quot; &amp; &quot;/u&quot; &amp; &quot;&gt; is already registered.&quot; &amp; &quot;&lt;&quot; &amp; &quot;br&quot; &amp; &quot;&gt;&quot; &amp; &quot;Please register using a different email address.&quot; End If End If End Sub 2002-09-10T15:53:22-04:0065845http://forums.asp.net/p/32497/65845.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID Mike, would it be possible for you to post a more complete example of of Global.aspx.vb and register.aspx.vb. I have made extensive changes to my userDb class and my entire registration process and it seems that I am just missing something with this. I have the code working in Security.vb and I can call UserInfo.whatever,but I seem to still have a bug with the registration part. If I could see the entire code of these files I know I will see my problem. Any help would be appreciated. Bruce 2002-10-10T12:10:57-04:0066010http://forums.asp.net/p/32497/66010.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID Here is my entire global.asax and register.aspx.vb files (I also attached my UserInfo class): GLOBAL.ASAX Imports System.Security Imports System.Security.Principal Imports System.Web.Security Namespace ASPNetPortal3 Public Class Global Inherits System.Web.HttpApplication '********************************************************************* ' ' Application_BeginRequest Event ' ' The Application_BeginRequest method is an ASP.NET event that executes ' on each web request into the portal application. The below method ' obtains the current tabIndex and TabId from the querystring of the ' request -- and then obtains the configuration necessary to process ' and render the request. ' ' This portal configuration is stored within the application's &quot;Context&quot; ' object -- which is available to all pages, controls and components ' during the processing of a single request. ' '********************************************************************* Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) Dim tabIndex As Integer = 0 Dim tabId As Integer = 0 ' Get TabIndex from querystring If Not (Request.Params(&quot;tabindex&quot;) Is Nothing) Then tabIndex = CInt(Request.Params(&quot;tabindex&quot;)) End If ' Get TabID from querystring If Not (Request.Params(&quot;tabid&quot;) Is Nothing) Then tabId = CInt(Request.Params(&quot;tabid&quot;)) End If ' ibsextra 14 - Support root folder - build Application(&quot;AppPath&quot;) to replace &quot;~&quot; or Request.ApplicationPath If Application(&quot;AppPath&quot;) = Nothing Then Dim sAbsUri As String = Request.Url.AbsoluteUri Dim sRawUrl As String = Request.RawUrl If Request.ApplicationPath = &quot;/&quot; Then Application(&quot;AppPath&quot;) = Left(sAbsUri, Len(sAbsUri) - Len(sRawUrl)) Else Application(&quot;AppPath&quot;) = Left(sAbsUri, Len(sAbsUri) - Len(sRawUrl)) &amp; Request.ApplicationPath End If End If Context.Items.Add(&quot;PortalSettings&quot;, New PortalSettings(tabIndex, tabId)) End Sub '********************************************************************* ' ' Application_AuthenticateRequest Event ' ' If the client is authenticated with the application, then determine ' which security roles he/she belongs to and replace the &quot;User&quot; intrinsic ' with a custom IPrincipal security object that permits &quot;User.IsInRole&quot; ' role checks within the application ' ' Roles are cached in the browser in an in-memory encrypted cookie. If the ' cookie doesn't exist yet for this session, create it. ' '********************************************************************* Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) If Request.IsAuthenticated = True Then Dim roles() As String ' Create the roles cookie if it doesn't exist yet for this session. If Request.Cookies(&quot;portalroles&quot;) Is Nothing Then ' Get roles from UserRoles table, and add to cookie Dim _user As New UsersDB() ' todo 9c - change from user email to user id? roles = _user.GetRoles(UserInfo.Email(User.Identity.Name)) ' Create a string to persist the roles Dim roleStr As String = &quot;&quot; Dim role As String For Each role In roles roleStr &#43;= role roleStr &#43;= &quot;;&quot; Next role ' Create a cookie authentication ticket. ' version ' user name ' issue time ' expires every hour ' don't persist cookie ' roles ' todo 9c - change from user email to user id? Dim ticket As New FormsAuthenticationTicket(1, _ UserInfo.Email(Context.User.Identity.Name), _ DateTime.Now, _ DateTime.Now.AddHours(1), _ False, _ roleStr) ' Encrypt the ticket Dim cookieStr As String = FormsAuthentication.Encrypt(ticket) ' Send the cookie to the client Response.Cookies(&quot;portalroles&quot;).Value = cookieStr Response.Cookies(&quot;portalroles&quot;).Path = &quot;/&quot; Response.Cookies(&quot;portalroles&quot;).Expires = DateTime.Now.AddMinutes(1) Else ' Get roles from roles cookie Dim ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(Context.Request.Cookies(&quot;portalroles&quot;).Value) 'convert the string representation of the role data into a string array Dim userRoles As New ArrayList() Dim role As String For Each role In ticket.UserData.Split(New Char() {&quot;;&quot;c}) userRoles.Add(role) Next role roles = CType(userRoles.ToArray(GetType(String)), String()) End If ' Request.Cookies(&quot;portalroles&quot;) Is Nothing ' Add our own custom principal to the request containing the roles in the auth ticket Context.User = New GenericPrincipal(Context.User.Identity, roles) If Request.Cookies(&quot;portaluserinfo&quot;) Is Nothing Then Else End If ' Request.Cookies(&quot;portaluser&quot;) Is Nothing End If ' Request.IsAuthenticated = True End Sub End Class End Namespace REGISTER.ASPX.VB Imports System.Web.Security Namespace ASPNetPortal3 Public Class Register Inherits System.Web.UI.Page Protected WithEvents Name As System.Web.UI.WebControls.TextBox Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator Protected WithEvents Email As System.Web.UI.WebControls.TextBox Protected WithEvents RegularExpressionValidator1 As System.Web.UI.WebControls.RegularExpressionValidator Protected WithEvents RequiredFieldValidator2 As System.Web.UI.WebControls.RequiredFieldValidator Protected WithEvents Password As System.Web.UI.WebControls.TextBox Protected WithEvents RequiredFieldValidator3 As System.Web.UI.WebControls.RequiredFieldValidator Protected WithEvents ConfirmPassword As System.Web.UI.WebControls.TextBox Protected WithEvents RequiredFieldValidator4 As System.Web.UI.WebControls.RequiredFieldValidator Protected WithEvents CompareValidator1 As System.Web.UI.WebControls.CompareValidator Protected WithEvents RegisterBtn As System.Web.UI.WebControls.LinkButton Protected WithEvents Message As System.Web.UI.WebControls.Label #Region &quot; Web Form Designer Generated Code &quot; 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub RegisterBtn_Click(ByVal sender As Object, ByVal E As EventArgs) Handles RegisterBtn.Click ' Only attempt a login if all form fields on the page are valid If Page.IsValid = True Then ' Add New User to Portal User Database Dim accountSystem As New ASPNetPortal3.UsersDB() ' ibsextra 9 - add user id/name to user.identity - set userName in AuthCookie to UserInfo ' 1. dim userid and set to new user id returned by AddUser ' 2. in IF statement, check userId vs. accountSystem.AddUser(Name.Text, Email.Text, Password.Text) ' 3. change email.text to userInfo.InfoString(...) in SetAuthCookie Dim UserID As Integer UserID = accountSystem.AddUser(Name.Text, Email.Text, Password.Text) If UserID Then ' Set the user's authentication name to the userId FormsAuthentication.SetAuthCookie(UserInfo.InfoString(UserID, Name.Text, Email.Text), False) ' Redirect browser back to home page' Response.Redirect(&quot;~/DesktopDefault.aspx&quot;) Else Message.Text = &quot;Registration Failed! &lt;&quot; &amp; &quot;u&quot; &amp; &quot;&gt;&quot; &amp; Email.Text &amp; &quot;&lt;&quot; &amp; &quot;/u&quot; &amp; &quot;&gt; is already registered.&quot; &amp; &quot;&lt;&quot; &amp; &quot;br&quot; &amp; &quot;&gt;&quot; &amp; &quot;Please register using a different email address.&quot; End If End If End Sub End Class End Namespace USERINFO '********************************************************************* ' ' ibsextra 9 - add user id/name to user.identity - UserInfo Class ' ' The UserInfo class is used to build and parse a string of user information ' for storage in the context.user.identity.name property (this is populated ' via the forms authentication ticket created during signin) ' '********************************************************************* Public Class UserInfo Public Shared Function InfoString(ByVal ID As String, ByVal Name As String, ByVal Email As String) As String Return ID &#43; &quot;|&quot; &#43; Name &#43; &quot;|&quot; &#43; Email End Function Public Shared Function ID(ByVal UserInfo As String) As String Dim items() As String items = UserInfo.Split(&quot;|&quot;) Return items(0) Dim s As String = HttpContext.Current.User.Identity.Name End Function Public Shared Function ID() As String Dim items() As String items = HttpContext.Current.User.Identity.Name.Split(&quot;|&quot;) Return items(0) End Function Public Shared Function Name(ByVal UserInfo As String) As String Dim items() As String items = UserInfo.Split(&quot;|&quot;) Return items(1) End Function Public Shared Function Name() As String Dim items() As String items = HttpContext.Current.User.Identity.Name.Split(&quot;|&quot;) Return items(1) End Function Public Shared Function Email(ByVal UserInfo As String) As String Dim items() As String items = UserInfo.Split(&quot;|&quot;) Return items(2) End Function Public Shared Function Email() As String Dim items() As String items = HttpContext.Current.User.Identity.Name.Split(&quot;|&quot;) Return items(2) End Function end class 2002-10-10T15:21:51-04:0066018http://forums.asp.net/p/32497/66018.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID Thanks Mike, since I had changed the RegisterBtn_Click sub so much that was where I was missing it at. I got it now. Bruce 2002-10-10T15:35:32-04:0066066http://forums.asp.net/p/32497/66066.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID One reason is running multiple portals from one db (as I do). You would want unique registrations per portal. You would not want to key off of the email address. 2002-10-10T16:33:31-04:0079745http://forums.asp.net/p/32497/79745.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID Does somebody have this allready done in C#? Thanks! 2002-11-03T17:56:31-05:00119446http://forums.asp.net/p/32497/119446.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID For anyone that is interested here is the code in c#: The User Info Class to add to the bottom of Secrity.cs: public class UserInfo { public string InfoString(string Id , string Name, string Email) { return Id &#43; &quot;|&quot; &#43; Name &#43; &quot;|&quot; &#43; Email ; } public string Id(string UserInfo) { string []items; items = UserInfo.Split(new Char[] {'|'}) ; return items[0] ; } public string Name(string UserInfo) { string []items; items = UserInfo.Split(new Char[] {'|'}) ; return items[1] ; } public string Email(string UserInfo) { string []items; items = UserInfo.Split(new Char[] {'|'}) ; return items[2] ; } } *************************************************************** The code at the bottom of The login method to return the string if ((parameterUserName.Value != null) &amp;&amp; (parameterUserName.Value != System.DBNull.Value)) { UserInfo Info = new UserInfo(); string UserString = Info.InfoString((parameterUserId.Value).ToString(), ((string)parameterUserName.Value).Trim(), ((string)parameterEmail.Value).Trim()) ; return UserString; } ***************************************************************** The method to add the email to the context: if (Request.IsAuthenticated == true) { String[] roles; // Create the roles cookie if it doesn't exist yet for this session. if ((Request.Cookies[&quot;portalroles&quot;] == null) || (Request.Cookies[&quot;portalroles&quot;].Value == &quot;&quot;)) { // Get roles from UserRoles table, and add to cookie UsersDB user = new UsersDB(); UserInfo Info = new UserInfo(); roles = user.GetRoles(Info.Email(Context.User.Identity.Name)); // Create a string to persist the roles String roleStr = &quot;&quot;; foreach (String role in roles) { roleStr &#43;= role; roleStr &#43;= &quot;;&quot;; } // Create a cookie authentication ticket. FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, // version Info.Email(Context.User.Identity.Name), // user name DateTime.Now, // issue time DateTime.Now.AddHours(1), // expires every hour false, // don't persist cookie roleStr // roles ); // Encrypt the ticket String cookieStr = FormsAuthentication.Encrypt(ticket); // Send the cookie to the client Response.Cookies[&quot;portalroles&quot;].Value = cookieStr; Response.Cookies[&quot;portalroles&quot;].Path = &quot;/&quot;; Response.Cookies[&quot;portalroles&quot;].Expires = DateTime.Now.AddMinutes(1); } ************************************************************** This Should help you to get it going if you follow the VB post above and use this c# code as reference Cheers Anthony 2003-01-09T11:05:57-05:00121237http://forums.asp.net/p/32497/121237.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID Anthony, I have implemented the C3 version which youmentioned and also Mike's instructions. On doing so , in the DesktopPortalBanner.ascx I replaced the line WelcomeMessage.Text = &quot;Welcome &quot; &#43; Context.User.Identity.Name &#43; &quot;! &lt;&quot; &#43; &quot;span class=Accent&quot; &#43; &quot;&gt;|&lt;&quot; &#43; &quot;/span&quot; &#43; &quot;&gt;&quot;; replaced with UserInfo Uname = new UserInfo(); WelcomeMessage.Text = &quot;Welcome &quot; &#43; Uname.Name(Context.User.Identity.Name) &#43; &quot;! &lt;&quot; &#43; &quot;span class=Accent&quot; &#43; &quot;&gt;|&lt;&quot; &#43; &quot;/span&quot; &#43; &quot;&gt;&quot;; and I am getting this err could you pls suggest Server Error in '/portalcsvsmc' Application. -------------------------------------------------------------------------------- Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [IndexOutOfRangeException: Index was outside the bounds of the array.] ASPNetPortal.UserInfo.Name(String UserInfo) ASPNetPortal.DesktopPortalBanner.Page_Load(Object sender, EventArgs e) System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain() 2003-01-11T15:01:31-05:00121288http://forums.asp.net/p/32497/121288.aspx/1?Re+Extending+Context+User+Identity+Name+to+add+USERIDRe: Extending Context.User.Identity.Name to add USERID Folks, there's a more elegant way of achieving this. I had the same requirements (wanting to store additional information besides just the name (like an ID, a 'friendly' name for display purposes, etc.). To solve this, I created a new identity object (inherited the GenericIdentity object, which is what the Context.User object is). I added new properties to store the data I was interested in (friendly name, user id, etc.) and use this object to store in the cookie. I can post code if anyone is interested. 2003-01-11T15:57:35-05:00