DhcpEnumSubnetClientsV5 function (dhcpsapi.h)

The DhcpEnumSubnetClientsV5 function returns an enumerated list of clients with served IP addresses in the specified subnet. This function extends the features provided in the DhcpEnumSubnetClients function by returning a list of DHCP_CLIENT_INFO_V5 structures that contain the specific client type (DHCP and/or BOOTP) and the IP address state.

Syntax

DWORD DHCP_API_FUNCTION DhcpEnumSubnetClientsV5(
  [in]      DHCP_CONST WCHAR            *ServerIpAddress,
  [in]      DHCP_IP_ADDRESS             SubnetAddress,
  [in, out] DHCP_RESUME_HANDLE          *ResumeHandle,
  [in]      DWORD                       PreferredMaximum,
  [out]     LPDHCP_CLIENT_INFO_ARRAY_V5 *ClientInfo,
  [out]     DWORD                       *ClientsRead,
  [out]     DWORD                       *ClientsTotal
);

Parameters

[in] ServerIpAddress

A UNICODE string that specifies the IP address or hostname of the DHCP server.

[in] SubnetAddress

A value containing the IP address of the subnet gateway. If this parameter is set to 0, then the DHCP clients for all IPv4 subnets defined on the DHCP server are returned.

[in, out] ResumeHandle

A pointer to a handle that identifies the enumeration operation. Initially, this value should be zero, with a successful call returning the handle value used for subsequent enumeration requests. For example, if PreferredMaximum is set to 1000 bytes, and 2000 bytes worth of subnet client information structures are stored on the server, the resume handle can be used after the first 1000 bytes are retrieved to obtain the next 1000 on a subsequent call, and so forth.

[in] PreferredMaximum

The preferred maximum number of bytes of subnet client information structures to return. If the number of remaining unenumerated options (in bytes) is less than this value, then that amount will be returned.

[out] ClientInfo

A pointer to a DHCP_CLIENT_INFO_ARRAY_V5 structure containing information on the clients served under this specific subnet. If no clients are available, this field will be null.

[out] ClientsRead

A pointer to a value that specifies the number of clients returned in ClientInfo.

[out] ClientsTotal

A pointer to a value that specifies the total number of clients for the specified subnet stored on the DHCP server.

Return value

The DhcpEnumSubnetClientsV5 function returns ERROR_SUCCESS upon success.

On error, the function returns one of the DHCP Server Management API Error Codes.

Return code Description
ERROR_ACCESS_DENIED
The call was performed by a client who is not a member of the "DHCP Administrators" security group.
ERROR_DHCP_JET_ERROR
An error occurred while accessing the DHCP server's database.
ERROR_MORE_DATA
There are still un-enumerated client lease records on the DHCP server for the provided IPv4 subnet. Please call this function again with the returned resume handle to obtain more of them.

Remarks

The caller of this function must release the memory used by the DHCP_CLIENT_INFO_ARRAY_V5 structure returned in buffer pointed to by the ClientInfo parameter when the information is no longer needed.

Requirements

Requirement Value
Minimum supported client None supported
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header dhcpsapi.h
Library Dhcpsapi.lib
DLL Dhcpsapi.dll

See also

DHCP_CLIENT_INFO_ARRAY_V5

DHCP_IP_ADDRESS

DHCP_RESUME_HANDLE

DhcpEnumSubnetClients