Solved

Code for Workstation ID.

Posted on 2008-06-24
5
188 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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
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.

724 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