Solved

Code for Workstation ID.

Posted on 2008-06-24
5
180 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
Comment Utility
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
Comment Utility



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
Comment Utility
Ptakja, I'm using NET 2.0, Visual Studios 2005.
0
 

Author Comment

by:Mr_Fulano
Comment Utility
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
Comment Utility
thank you..
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

18 Experts available now in Live!

Get 1:1 Help Now