Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How do I capture my network userid and display it on a form?

How do I capture my network userid and display it on a form?

Scheduled Pinned Locked Moved Visual Basic
questionsysadmin
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rashar
    wrote on last edited by
    #1

    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

    K 1 Reply Last reply
    0
    • R 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

      K Offline
      K Offline
      KreativeKai
      wrote on last edited by
      #2

      In VS 2005 you can use My.User.Name to retrieve the current user id. :) Lost in the vast sea of .NET

      R 1 Reply Last reply
      0
      • K KreativeKai

        In VS 2005 you can use My.User.Name to retrieve the current user id. :) Lost in the vast sea of .NET

        R Offline
        R Offline
        Rashar
        wrote on last edited by
        #3

        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

        K F 3 Replies Last reply
        0
        • R 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

          K Offline
          K Offline
          KreativeKai
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • R 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

            F Offline
            F Offline
            FrankyT
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • R 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

              K Offline
              K Offline
              KreativeKai
              wrote on last edited by
              #6

              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\jsmith MsgBox(System.Environment.UserName) The messagebox displayed shows: jsmith MsgBox(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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups