0

I'm currently working on a project where I (among other things) need to find the MAC address for a remote computer. The problem is that i'm restriced to only accessing the computer throught SQL queries. (so I can't use WMI)

The remote computer is running Windows Server 2000, and Ms SQL server 2000.

I know the IP of the remote computer and I am able to log in with the admin account. How can I get the MAC address(preferably all of them) from the remote computer?

Thankful for answers.

  • NOTE: I am able to access the windows registry on the remote computer, throught SQL. Is there a static path to any key/value containing the MAC? – Darth_Peter Aug 07 '13 at 11:22

3 Answers3

1

I think that some kind of external call via xp_cmdshell is your only option. There is a likelihood that this feature may be disabled on your SQL Server (with good reason).

Something like

 Create table #results(data varchar(250))
 Insert #results
 exec master..xp_cmdshell 'ipconfig /all'

 select * from #results where data like 'physical address%'

Further to your comment - you may find it under in the registry under the

HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}

key, but if and where will be hardware configuration dependent.

podiluska
  • 50,950
  • 7
  • 98
  • 104
  • Unfortunately xp_cmdshell is deactivated, so I can't do that – Darth_Peter Aug 07 '13 at 11:29
  • That's what i found at all tutorials, but it seems that for some reason there is no "NetworkAddress"-key for any of the network adapters. And there are no other value looking anything like a MAC address. – Darth_Peter Aug 07 '13 at 12:23
  • @Darth_Peter Then it looks like you're stuck. You may have to adjust your requirements. – podiluska Aug 07 '13 at 12:25
  • I'm afraid that you are right. I'll see if i might work around my restrictions or if I can solve it in another way – Darth_Peter Aug 07 '13 at 12:28
0

According to this, it doesn't seem you can. If you were using SQL Server 2005+, I'd think you could code up something in SQLCLR to do this without too much effort.

DavidN
  • 5,117
  • 2
  • 20
  • 15
0

I solved it for my computer

//dont mind the makeQuery and querySrv

ResultTable res = makeQuery(querySrv,("USE Master; EXEC xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\\Description\\Microsoft\\rpc\\UuidTemporaryData', 'NetworkAddress'"));
    byte[] bMac =(byte[])res.getRow(0).data[1];
    String mac = String.format("%02X:%02X:%02X:%02X:%02X:%02X", bMac[0], bMac[1], bMac[2], bMac[3], bMac[4], bMac[5]);

This should work for other windows server 2000 servers

Thanks to @morgano for help with the formating and byte/hex converting