Search code examples
c#active-directorymac-addressdhcpwake-on-lan

Get mac address from IP using DHCP?


I am trying to create scripts/services that allow for waking PCs in a windows domain via WOL. Now i want to give the user the option to select an AD container as a starting point for the waking of PCs contained within. My initial thought is using DHCP as a repository to query for MAC addresses given the hostnames (which i can easily enough pull from AD given the container).

Is there a way to programmatically query the DHCP service/server, passing hostnames and recover the associated MAC addresses?

Or, is there a better/easier way to solve my problem?


Solution

  • Try dhcpexim.exe from microsoft.

    or, if you prefer using pure C. DhcpEnumSubnetClientsV4