?
Solved

Code for Workstation ID.

Posted on 2008-06-24
5
Medium Priority
?
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

770 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