Solved

Code for Workstation ID.

Posted on 2008-06-24
5
185 Views
Last Modified: 2010-04-23
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
Comment
Question by:Mr_Fulano
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:ptakja
ID: 21861318
What version of the .NET Framework are you coding against? 1.1? 2.0? 3.0? 3.5?
0
 
LVL 10

Accepted Solution

by:
margajet24 earned 500 total points
ID: 21861663



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
 

Author Comment

by:Mr_Fulano
ID: 21862417
Ptakja, I'm using NET 2.0, Visual Studios 2005.
0
 

Author Comment

by:Mr_Fulano
ID: 21862465
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
 
LVL 10

Expert Comment

by:margajet24
ID: 21862481
thank you..
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question