Solved

Get remote IP or MAC

Posted on 2007-03-23
2
619 Views
Last Modified: 2013-12-17
I am trying to get the IP address or MAC id of a computer on the same lan.  I would like to use .NET calls to do this.  I found the following but it seems to require Admin rights to the computer.  Is there any way to do this without using windows API calls or a High Level Login. I would be alright with the ability to do it with a restricted domain user login though

I found the code here
http://www.experts-exchange.com/Programming/Languages/.NET/Q_21469047.html

    Public Shared Function GetMAC(ByVal ComputerName As String)
        Dim MAC As String = ""
        Try
            Dim query As String = "SELECT * FROM Win32_NetworkAdapterConfiguration"

            Dim searchAddresses As New ManagementObjectSearcher(query)
            Dim ConOpts As New ConnectionOptions()

            ConOpts.Password = "Pswd"
            ConOpts.Username = "Domain\LoginName"
            Dim SearchScope As ManagementScope = New ManagementScope("\\" & ComputerName & "\root\cimv2", ConOpts)
            searchAddresses.Scope = SearchScope

            Dim objColl As ManagementObjectCollection
            objColl = searchAddresses.Get()
            Debug.Print(objColl.ToString)
            For Each Adapter As ManagementObject In objColl
                If Adapter("MacAddress") IsNot Nothing Then
                    MAC = Adapter("MacAddress") '(0)
                End If
            Next
        Catch ex As Exception
            Debug.Print(ex.Message & vbCrLf & vbCrLf & ex.StackTrace)
        End Try

        Return IP
    End Function
0
Comment
Question by:Corey2
2 Comments
 
LVL 13

Accepted Solution

by:
Corey2 earned 0 total points
ID: 18781937
I found it
Dim HostIP() As System.Net.IPAddress = System.Net.Dns.GetHostEntry(ForComputerName).AddressList
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

15 Experts available now in Live!

Get 1:1 Help Now