The R_DhcpV4SetOptionValues method sets the specified option values for a policy at the specified level.
DWORD R_DhcpV4SetOptionValues( [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress, [in] DWORD Flags, [in, string, unique] WCHAR* PolicyName, [in, string, unique] WCHAR* VendorName, [in] LPDHCP_OPTION_SCOPE_INFO ScopeInfo, [in] LPDHCP_OPTION_VALUE_ARRAY OptionValues );
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. |
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 to which the option value is being set. This parameter is optional. If the vendor class is not specified, the option value is set for a 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 values are set.
OptionValues: This is a pointer to a type DHCP_OPTION_VALUE_ARRAY structure (section 2.2.1.2.43) that points to the location that contains one or more option identifiers, along with the values.
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. |
|
0x00004E32 ERROR_DHCP_NOT_RESERVED_CLIENT |
The specified DHCP client is not a reserved client. |
|
0x00004E4C ERROR_DHCP_CLASS_NOT_FOUND |
The class name being used is unknown or incorrect. |
|
0x00004E8FL ERROR_DHCP_POLICY_NOT_PRESENT |
The specified policy name does not exist. |
|
0x00004EA8L ERROR_DHCP_POLICY_FQDN_OPTION_UNSUPPORTED |
The option value cannot be specified because the policy contains an FQDN-based condition. |
The opnum field value for this method is 102.
When processing this call, the DHCP server MUST do the following:
If the OptionValues parameter or the ScopeInfo parameter is NULL, the method returns ERROR_INVALID_PARAMETER.
The Flags parameter MUST pass one of the validations given in the Flags parameter description. Otherwise, the method returns ERROR_INVALID_PARAMETER.
If the ScopeType member in the ScopeInfo parameter is DhcpReservedOptions enumeration value or DhcpMScopeOptions enumeration value and the PolicyName parameter is not NULL, the method returns ERROR_INVALID_PARAMETER.
If the Values member of the OptionValues parameter is NULL, return ERROR_INVALID_PARAMETER.
Validate whether this method is authorized for read/write access as specified in section 3.5.5. If not, return ERROR_ACCESS_DENIED.
Validate whether the policy specified in the PolicyName parameter contains a condition of Type DhcpAttrFqdn or DhcpAttrFqdnSingleLabel, as defined in the DHCP_POL_ATTR_TYPE (section 2.2.1.1.23) enumeration. If it does, and if any of the values for the OptionId parameters specified in the OptionValues parameter specify values other than DNS settings (81) or lease time (51), return ERROR_DHCP_POLICY_FQDN_OPTION_UNSUPPORTED.<74>
For each Values member in the DHCP_OPTION_VALUE structure element in the OptionValues parameter of the DHCP_OPTION_VALUE_ARRAY structure, validate the data pointed to by the Value member. If the Elements member of the DHCP_OPTION_DATA structure is NULL or the NumElements member is 0, return ERROR_INVALID_PARAMETER.
If the VendorName parameter is not NULL, retrieve the DHCPv4ClassDef ADM element entry corresponding to the VendorName parameter from the server ADM element DHCPv4ClassDefList. If the DHCPv4ClassDef ADM element entry is not found, return ERROR_DHCP_CLASS_NOT_FOUND. If the VendorName parameter is NULL, it refers to the default vendor class (see section 3.1.1.11).
If the ScopeType member in the ScopeInfo parameter is set to DhcpDefaultOptions:
Iterate through the server ADM element DHCPv4OptionDefList and retrieve the DHCPv4OptionDef.DHCPv4ClassedOptDefList ADM element corresponding to the vendor class specified by the VendorName parameter. If there is no DHCPv4OptionDef ADM element entry corresponding to the specified vendor class, return ERROR_DHCP_CLASS_NOT_FOUND.
For each DHCP_OPTION_VALUE structure in the DHCP_OPTION_VALUE_ARRAY structure in the OptionValues parameter:
If there is no DHCPv4ClassedOptDef ADM element entry in the DHCPv4ClassedOptDefList ADM element corresponding to the OptionID member in the DHCP_OPTION_VALUE structure, return ERROR_DHCP_OPTION_NOT_PRESENT.
Modify the retrieved DHCPv4ClassedOptDef entry with information in the corresponding DHCP_OPTION_VALUE structure element.
Return ERROR_SUCCESS.
If the ScopeType member in the ScopeInfo parameter contains the DhcpGlobalOptions enumeration value:
Retrieve the server ADM element DHCPv4ServerPolicyList. Retrieve the DHCPv4Policy ADM element from the DHCPv4ServerPolicyList ADM element that has the same name as the PolicyName parameter. If there is no policy with the specified name, return ERROR_DHCP_POLICY_NOT_FOUND.
Retrieve each DHCPv4PolicyOptionValue ADM element from the server ADM element DHCPv4ServerPolicyOptionValuesList. Get the DHCPv4PolicyOptionValue ADM element for which the DHCPv4PolicyOptionValue.PolicyName ADM element and the DHCPv4PolicyOptionValue.VendorName ADM element match the PolicyName parameter and the VendorName parameter passed to the method.
For each DHCP_OPTION_VALUE structure in the OptionValues parameter, perform the following steps:
Retrieve the DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues ADM element list.
If there is a DHCPv4ClassedOptValue ADM element that contains the same OptionID ADM element as the OptionID member in the DHCP_OPTION_VALUE structure, delete the DHCPv4ClassedOptValue ADM element.
Create a DHCPv4ClassedOptValue ADM element with the OptionID ADM element set to the OptionID member in the DHCP_OPTION_VALUE structure and the data member of the DHCPv4ClassedOptValue ADM element set to the Value member in the DHCP_OPTION_VALUE structure passed to the method. Add the created DHCPv4ClassedOptValue ADM element to the DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues ADM element list.
After performing these steps for all DHCP_OPTION_VALUE structure elements in the OptionValues parameter, return ERROR_SUCCESS.
If the ScopeInfo parameter contains the SubnetScopeInfo member:
Retrieve the server ADM element DHCPv4ScopesList. Retrieve the DHCPv4Scope ADM element that contains the same IP address as the IP address in the SubnetScopeInfo member. If there is no scope with the specified IP address, return ERROR_DHCP_SUBNET_NOT_PRESENT.
Retrieve the DHCPv4Scope.DHCPv4ScopePolicyList ADM element. Retrieve the DHCPv4Policy ADM element from the DHCPv4Scope.DHCPv4ScopePolicyList ADM element with the specified PolicyName parameter. If there is no policy with the specified name, return ERROR_DHCP_POLICY_NOT_FOUND.
Retrieve each DHCPv4PolicyOptionValue ADM element from the scope ADM element DHCPv4Scope.DHCPv4ScopePolicyOptionValuesList. Get the DHCPv4PolicyOptionValue ADM element for which the DHCPv4PolicyOptionValue.PolicyName ADM element and the DHCPv4PolicyOptionValue.VendorName ADM element match the PolicyName parameter and the VendorName parameter passed to the method.
For each DHCP_OPTION_VALUE structure in the OptionValues parameter, perform the following steps:
Retrieve the DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues ADM element list.
If there is a DHCPv4ClassedOptValue ADM element that contains the same OptionID ADM element as the OptionID member in the DHCP_OPTION_VALUE structure, delete the DHCPv4ClassedOptValue ADM element.
Create a DHCPv4ClassedOptValue ADM element with the OptionID ADM element set to the OptionID member in the DHCP_OPTION_VALUE structure and the data member of the DHCPv4ClassedOptValue ADM element set to the Value member in the DHCP_OPTION_VALUE structure. Add the created DHCPv4ClassedOptValue ADM element to the DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues ADM element list, and return ERROR_SUCCESS.
After performing these steps for all DHCP_OPTION_VALUE structure elements in the OptionValues parameter, return ERROR_SUCCESS.
Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].