Retrieving Client Computer Name

Author Message
AntarcticAlicia

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 3/18/2005
  • Location: USA
  • Status: offline
Retrieving Client Computer Name Friday, March 18, 2005 4:48 AM (permalink)
0
I attempting to retrieve the user name and client machine name of the person logged on to a computer on our intranet in ASP.NET. This is just for logging purposes. I am able to retrieve the user name easily enough via "User.Identity.Name" or "System.Security.Principal.WindowsIdentity.GetCurrent().Name", however I cannot get the CLIENT machine name. I have searched high and low and everything I have tried returns the machine name of the server. Any suggestions? Much appreciated!
 
#1
    didorno

    • Total Posts : 361
    • Scores: 0
    • Reward points : 0
    • Joined: 2/12/2005
    • Location:
    • Status: offline
    Re: Retrieving Client Computer Name Tuesday, March 29, 2005 5:56 AM (permalink)
    0
    AntarcticAlicia, I did look for a solution, but
    I couldn't find one.[V]
    Should this be a security issue ?
    Possibly, you can try in the Command window
    the "net" and the "nbtstat" commands.
    You get the possible options with /? as parameter.
    Good luck.
     
    #2
      didorno

      • Total Posts : 361
      • Scores: 0
      • Reward points : 0
      • Joined: 2/12/2005
      • Location:
      • Status: offline
      Re: Retrieving Client Computer Name Tuesday, March 29, 2005 7:42 AM (permalink)
      0
      I played a bit with the command window.
      If I input "net view", then a list with computer
      names active on my LAN results. With
      "net view > pcnames.txt" you get the same results in
      that specified file.
      A script could take care for this command and
      thereafter use these computer names to search for
      the associated user names in the next way.

      ' Returns the user name of the user currently logged on
      ' to a remote computer. To use this script, replace
      ' RemoteComputer with the name of the remote computer
      ' you want to check.

      ' Script Code

      strComputer = "RemoteComputer"
      Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colComputer = objWMIService.ExecQuery _
      ("Select * from Win32_ComputerSystem")
      For Each objComputer in colComputer
      Wscript.Echo objComputer.UserName
      Next

      ' Source : The System Administration Scripting Guide,
      ' part of the Windows .NET Server Resource Kit.
      ' For more information, contact scripter@microsoft.com.


      I hope you can use this idea.
      <message edited by didorno on Wednesday, July 20, 2005 8:54 AM>
       
      #3
        netmarcos

        • Total Posts : 55
        • Scores: 0
        • Reward points : 0
        • Joined: 12/7/2004
        • Location: USA
        • Status: offline
        Re: Retrieving Client Computer Name Tuesday, March 29, 2005 7:53 AM (permalink)
        0
        Perhaps a WMI call to the IP address of the incoming session?

        On Error Resume Next
        strComputer = "111.222.33.4"
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
        For Each objItem in colItems
        Wscript.Echo "Name: " & objItem.Name
        Next
         
        #4
          AntarcticAlicia

          • Total Posts : 2
          • Scores: 0
          • Reward points : 0
          • Joined: 3/18/2005
          • Location: USA
          • Status: offline
          Re: Retrieving Client Computer Name Wednesday, March 30, 2005 9:42 AM (permalink)
          0
          I HAVE A SOLUTION! Thank you so much for the suggestions. I have not tried them yet but I plan to do so to see if they will work for me. For now I wanted let you know that I found something else that finally worked for me:

          Dim host As System.Net.IPHostEntry
          host = System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST"))
          strComputerName = host.HostName

          I suppose I was trying to make it too difficult. Thanks for everything! ~Alicia
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9