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. Retrieving Windows User name/ID

Retrieving Windows User name/ID

Scheduled Pinned Locked Moved Visual Basic
csharpasp-netdatabasesecurity
4 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
    robw1888
    wrote on last edited by
    #1

    Hi all I've created a ASP.NET/VB.NET application to maintain a database via a datagrid and was looking to retrieve the Windows username of the current user of the application so that when they click to update any changes they make, a field in the database will update showing that user as the last person to update that record. I've set the authentication to 'windows' in the webconfig file, could anyone point me to the code I would need to retrieve the windows username? Many Thanks

    Rob

    D D 2 Replies Last reply
    0
    • R robw1888

      Hi all I've created a ASP.NET/VB.NET application to maintain a database via a datagrid and was looking to retrieve the Windows username of the current user of the application so that when they click to update any changes they make, a field in the database will update showing that user as the last person to update that record. I've set the authentication to 'windows' in the webconfig file, could anyone point me to the code I would need to retrieve the windows username? Many Thanks

      Rob

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This is better asked in the ASP.NET Forum. I don't see how you're going to get the username from the client without some kind of authentication on the client side and sending that information to the server, possibly storing it in the session object. But, that's about as far as my very limited ASP.NET experience will take me on this one.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        This is better asked in the ASP.NET Forum. I don't see how you're going to get the username from the client without some kind of authentication on the client side and sending that information to the server, possibly storing it in the session object. But, that's about as far as my very limited ASP.NET experience will take me on this one.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

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

        Will do, thanks for the reply Dave.

        Rob

        1 Reply Last reply
        0
        • R robw1888

          Hi all I've created a ASP.NET/VB.NET application to maintain a database via a datagrid and was looking to retrieve the Windows username of the current user of the application so that when they click to update any changes they make, a field in the database will update showing that user as the last person to update that record. I've set the authentication to 'windows' in the webconfig file, could anyone point me to the code I would need to retrieve the windows username? Many Thanks

          Rob

          D Offline
          D Offline
          Dave Herren
          wrote on last edited by
          #4

          HttpContext.Current.User.Identity.Name.ToString() returns the domain and username seperated by a slash. The following will get the username. Dim UserName as String Dim UserLoginDomainAndID as string[] UserLoginDomainAndID = HttpContext.Current.User.Identity.Name.ToString().Split(new char [] {'\\'}) UserName = UserLoginDomainAndID[UserLoginDomainAndID.Length-1] I converted this from my c# code so appoligies if it's not quite vb.net, but it should be close. Oh and I used this on an asp.net site that did windows authentication. Unauthenticated this will give you nothing. Not certain what would be returned under other authentication.

          topcoderjax - Remember, Google is your friend.

          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