I have been assigned the task of creating an application that takes in a MAC address and creates a DHCP reservation for that MAC address. Is there any API built into .NET to easily accomplish this?
Asked
Active
Viewed 2,618 times
1 Answers
1
When I was writing apps for infrastructure there was a COM library called Dhcpobjs.dll in the Windows 2000 Resource Kit. This could be dynamically loaded by a VBScript using IDispatch like so:
Set DhcpMgr = CreateObject("Dhcp.Manager")
Set DhcpServer = DhcpMgr.Servers.Connect("192.130.1.5")
I'd google [ CreateObject Dhcpobjs.dll ] and see what you get. You'd likely be able to add a reference to this lib from your VS project.
I'm surprised there's no managed library for simple Windows infra management. Also look in the TechNet script gallery on microsoft.com for other useful stuff.
Good luck,
Luke
EDIT: This may be of interest to people working or assigned similar duties:
Linq to Active Directory: http://linqtoad.codeplex.com/

Luke Puplett
- 42,091
- 47
- 181
- 266
-
Found this googling exactly those two terms :) http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.general/2006-12/msg00393.html – Luke Puplett Oct 02 '09 at 20:23
-
1This is the classic answer that I've always used, but dhcpobjs.dll is no longer supported after Windows 2000, and Microsoft never created a 64 bit version of it, so you're out of luck in recent Windows server versions. For Windows 2003+, you could try shelling it out to netsh. – Luc VdV May 30 '16 at 09:55
-
@Matt Maybe you can do it with [Add-DhcpServerv4Reservation](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/add-dhcpserverv4reservation?view=win10-ps) PowerShell and [Executing PowerShell scripts from C#](https://blogs.msdn.microsoft.com/kebab/2014/04/28/executing-powershell-scripts-from-c/) but i don't test it – Amir Azad Nov 16 '19 at 05:26