3.1.4.9 R_DhcpCreateOption (Opnum 8)
The R_DhcpCreateOption method creates an option definition of the specified option for the default user class and vendor class pair at the default option level. The OptionID parameter specifies the identifier of the option.
-
DWORD R_DhcpCreateOption( [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress, [in] DHCP_OPTION_ID OptionID, [in, ref] LPDHCP_OPTION OptionInfo );
ServerIpAddress: The IP address/host name of the DHCP server. This parameter is unused.
OptionID: This is of type DHCP_OPTION_ID (section 2.2.1.2.3), containing the option identifier for the option being created.
OptionInfo: This is a pointer to a DHCP_OPTION (section 2.2.1.2.25) structure that contains the information about the option definition.
Return Values: A 32-bit unsigned integer value that indicates return status. A return value ERROR_SUCCESS (0x00000000) indicates that the operation was completed successfully, else it contains a Win32 error code, as specified in [MS-ERREF]. This error code value can correspond to a DHCP-specific failure, which takes a value between 20000 and 20099, or any generic failure.
-
Return value/code
Description
0x00000000
ERROR_SUCCESS
The call was successful.
0x00004E29
ERROR_DHCP_OPTION_EXITS
The specified option already exists on the DHCP server database.
0x00004E2D
ERROR_DHCP_JET_ERROR
An error occurred while accessing the DHCP server database.
The opnum field value for this method is 8.
When processing this call, the DHCP server MUST do the following:
Validate whether this method is authorized for read/write access per section 3.5.5. If not, return the error ERROR_ACCESS_DENIED.
Validate the DefaultValue data structure, pointed to by the OptionInfo parameter, by checking that its Elements member is not NULL and that its NumElements member is not zero. If either check fails, return ERROR_INVALID_PARAMETER.
Iterate though the server Abstract Data Model (ADM) element DHCPv4OptionDefList, and retrieve the DHCPv4ClassedOptDefList ADM element corresponding to the DHCPv4OptionDef ADM element entry whose UserClass and VendorClass ADM element fields are NULL. If there is no DHCPv4OptionDef ADM element entry whose UserClass and VendorClass fields are NULL, return ERROR_DHCP_CLASS_NOT_FOUND.
Iterate through the DHCPv4ClassedOptDefList ADM element; if there is any DHCPv4ClassedOptDef ADM element entry corresponding to that specific OptionID parameter, return the error ERROR_DHCP_OPTION_EXITS.
Create a DHCPv4ClassedOptDef ADM element object, and insert it into the DHCPv4ClassedOptDefList ADM element. The DHCPv4ClassedOptDef ADM element object is initialized with information in the OptionInfo input parameter.
Return ERROR_SUCCESS.
Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].