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
Public Shared Function GetMAC(ByVal ComputerName As String)
Dim MAC As String = ""
Dim query As String = "SELECT * FROM Win32_NetworkAdapterConfig
Dim searchAddresses As New ManagementObjectSearcher(q
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()
For Each Adapter As ManagementObject In objColl
If Adapter("MacAddress") IsNot Nothing Then
MAC = Adapter("MacAddress") '(0)
Catch ex As Exception
Debug.Print(ex.Message & vbCrLf & vbCrLf & ex.StackTrace)