[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Code for Workstation ID.

Hi, I have an application that is run from a shared drive. Different users connect to it and run independent sessions on their workstations at their desks. I've built in some error reporting into my App and each of those "errors" or incidents gets logged to a text file on the host's HDD.

My log entries specify the Date and Time of the occurrence, and a brief description of the incident. I can also identify who caused the error by logging their user ID. However, I can't tell which workstation caused the error. Is there a way to capture some sort of workstation ID, or the IP address of the workstation so I can put that into my logs as well?

Thanks,
Fulano
0
Mr_Fulano
Asked:
Mr_Fulano
  • 2
  • 2
1 Solution
 
ptakjaCommented:
What version of the .NET Framework are you coding against? 1.1? 2.0? 3.0? 3.5?
0
 
margajet24Commented:



Imports System
Imports System.Net
 
Module Module1
 
    Sub Main()
        Dim strMachineName As String
 
        'Get the Host Name
        strMachineName = Dns.GetHostName()
        Console.WriteLine("Host Name: " + strMachineName)
 
        'Get the Host by Name
        Dim ipHost As IPHostEntry
        ipHost = Dns.GetHostByName(strMachineName)
 
        'You can also query the DNS database for info on a 
        'website like www.microsoft.com
        'In that case replace the above line as:
        'ipHost = Dns.GetHostByName("www.microsoft.com")
 
        'Get the list of addresses associated with the host in an array
        Dim ipAddr() As IPAddress = ipHost.AddressList
        Dim count As Integer
 
        'Enumerate the IP Addresses
        For count = 0 To ipAddr.GetUpperBound(0)
            Console.Write("IP Addresses {0}: {1} ", count, _
                ipAddr(count).ToString)
        Next
    End Sub
 
End Module

Open in new window

0
 
Mr_FulanoAuthor Commented:
Ptakja, I'm using NET 2.0, Visual Studios 2005.
0
 
Mr_FulanoAuthor Commented:
MargaJet24,

Great job!  You provided both the host name and the IP address, which was nice. I added points for you, since you helped with both.

Thanks,
Fulano
0
 
margajet24Commented:
thank you..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now