How do I capture my network userid and display it on a form?
-
Hi, I have a table called tblUsers that displays all my users. What I want to do is when the user launches my form, for it to say Welcome "userloginName" on a label. So my form has to check to see if it is a valid user against (tblUsers). How can I accomplish this? Thanks, Rashar
-
Hi, I have a table called tblUsers that displays all my users. What I want to do is when the user launches my form, for it to say Welcome "userloginName" on a label. So my form has to check to see if it is a valid user against (tblUsers). How can I accomplish this? Thanks, Rashar
In VS 2005 you can use My.User.Name to retrieve the current user id. :) Lost in the vast sea of .NET
-
In VS 2005 you can use My.User.Name to retrieve the current user id. :) Lost in the vast sea of .NET
Hi Thanks. That works nice. However, when I debug into the code, the value of My.User.Name shows me domain\username, Where I just want username. Is this possible? Thanks, Rashar
-
Hi Thanks. That works nice. However, when I debug into the code, the value of My.User.Name shows me domain\username, Where I just want username. Is this possible? Thanks, Rashar
Try this:
'String manipulation to split the domain and userid Dim strFullUserID As String = My.User.Name Dim strUserIDSection(1) As String strUserIDSection = strFullUserID.Split("\"c) strDomain = strUserIDSection(0) strUserID = strUserIDSection(1)
:) Lost in the vast sea of .NET -
Hi Thanks. That works nice. However, when I debug into the code, the value of My.User.Name shows me domain\username, Where I just want username. Is this possible? Thanks, Rashar
in 2k3 I always used system.environment.username which returned just the short name. or you coul djust substring the returned name since that convient "\" is a perfect dilimeter. dim y as string = system.environment.username dim x as string = y.substring(y.laastindexof("\") + 1, y.length) good luck hey...slang is the vernacular for the vernacular...wow
-
Hi Thanks. That works nice. However, when I debug into the code, the value of My.User.Name shows me domain\username, Where I just want username. Is this possible? Thanks, Rashar
FrankyT's post made me think... I tested the following in VS 2005 and received the results shown:
MsgBox(My.User.Name)
The messagebox displayed shows: COMPANY_DOMAIN\jsmithMsgBox(System.Environment.UserName)
The messagebox displayed shows: jsmithMsgBox(System.Environment.UserDomainName)
The messagebox displayed shows: COMPANY_DOMAIN Much simpler code than what I posted earlier. Hope this helps! :) Lost in the vast sea of .NET