The R_DhcpV4SetOptionValue method sets the option value for a policy at the specified level (scope or server).

  
 DWORD R_DhcpV4SetOptionValue(
     [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
     [in] DWORD Flags,
     [in] DHCP_OPTION_ID OptionID,
     [in, string, unique] WCHAR* PolicyName,
     [in, string, unique] WCHAR* VendorName,
     [in] LPDHCP_OPTION_SCOPE_INFO ScopeInfo,
     [in] LPDHCP_OPTION_DATA OptionValue
 );

ServerIpAddress: The IP address/host name of the DHCP server. This parameter is unused.

Flags: This is of type DWORD that specifies that the option value is set for a specific or default vendor class.

Value

Meaning

DHCP_FLAGS_OPTION_DEFAULT

0x00000000

The option definition is set for the default vendor class.

DHCP_FLAGS_OPTION_IS_VENDOR

0x00000003

If a bitwise AND operation with this bitmask yields a nonzero value, it indicates that the option definition is set for a specific vendor class.

OptionId: This is of type DHCP_OPTION_ID data type (section 2.2.1.2.3), containing the option ID of the option being set or modified.

PolicyName: A pointer to a null-terminated Unicode string that contains the name of the policy inside the subnet identified by the SubnetScopeInfo member of the ScopeInfo parameter for which the option value is being set.

VendorName: A pointer to a null-terminated Unicode string that contains the name of the vendor class for which the option value is being set. This parameter is optional. If the vendor class is not specified, the option value is set for the default vendor class.

ScopeInfo: This is a pointer to a type DHCP_OPTION_SCOPE_INFO structure (section 2.2.1.2.41) that contains information describing the DHCPv4 scope for which this option value is set. This value contains the server or scope level at which the option value is to be set.

OptionValue: A pointer to a type DHCP_OPTION_DATA structure (section 2.2.1.2.24) that contains the option value that is set for an option corresponding to the OptionId parameter.

The method does not perform any checks to ensure that the OptionValue parameter passed in is of the same OptionType member value as that of the option corresponding to the OptionId parameter passed in. It is the responsibility of the caller to ensure that the correct OptionType member value is used for the OptionValue parameter passed in. In case the OptionType member of the OptionValue parameter passed in is different from that of the option corresponding to the OptionId parameter, the behavior is undefined.

Return Values: A 32-bit unsigned integer value that indicates return status. A return value of ERROR_SUCCESS (0x00000000) indicates that the operation was completed successfully. Otherwise, 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 to any generic failure.

Return value/code

Description

0x00000000

ERROR_SUCCESS

The call was successful.

0x00004E25

ERROR_DHCP_SUBNET_NOT_PRESENT

The specified IPv4 subnet does not exist on the DHCP server.

0x00004E2A

ERROR_DHCP_OPTION_NOT_PRESENT

The specified option definition does not exist on the DHCP server database.

0x00004E4C

ERROR_DHCP_CLASS_NOT_FOUND

The class name being used is unknown or incorrect.

0x00004E8FL

ERROR_DHCP_POLICY_NOT_FOUND

The specified policy name does not exist.

0x00004EA8L

ERROR_DHCP_POLICY_FQDN_OPIION_UNSUPPORTED

The option value cannot be specified because the policy contains an FQDN-based condition.

The opnum field value for this method is 101.

When processing this call, the DHCP server MUST do the following:

Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].