Question

I'm using C# (Visual Studio 2010) to programmatically create a DHCP reservation.

I've used the information in this post to get the DHCPOBJECTS.DLL. Connecting to the DHCP server works well. I'm also able to create a new reservation or enumerate through existing reservations.

class CDHCP
{
    private Manager dhcpmgr;
    private Server dhcpsrvr;

    public CDHCP()
    {
        dhcpmgr = new Manager();
        dhcpsrvr = dhcpmgr.Servers.Connect("192.168.1.3");
    }

    public void create_reservation(string sName, string sAddress, string sDescription, string sMAC)
    {
        Reservation DHCPReservation = dhcpsrvr.Scopes["192.168.1.0"].Reservation.CreateNew();

        DHCPReservation.Name = sName;
        DHCPReservation.UniqueID = sMAC;
        DHCPReservation.Address = sAddress;
        DHCPReservation.Comment = sDescription;

        DHCPReservation.Update();
    }

    public void get_reservations()
    {
        List<Reservation> reservations = new List<Reservation>();

        for(int i = 1; i <= dhcpsrvr.Scopes.Count; i++)
        {
            for(int j = 1; j <= dhcpsrvr.Scopes[i].Reservations.Count; j++)
            {
                reservations.Add(dhcpsrvr.Scopes[i].Reserations[j]);
            }
        }
    }
}

Unfortunately when creating a new reservation the supported type is always set to "both". In our network we have to use only DHCP.

Anyone knows how to set the supported type to DHCP via the DHCPOBJECTS.DLL?

EDIT: Okay it seems that I'm not able to change this option via DHCPOBJECTS.DLL. Now I will try to realize this via the microsoft dhcp server management api

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top