Solved

Code for Workstation ID.

Posted on 2008-06-24
5
181 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now