DhcpGetClientInfo and Error 1783 in Vista

V

VladZ

Hello,

Sample Code below always returns error code 1783 in Vista (SP1) but works
fine in Windows XP (SP3). Is it bug or my mistake?

I'm use:

1) Windows Software Development Kit (SDK) for Windows Server 2008 and .NET
Framework 3.5
2) VS2005 (SP1)

-------------------------------------

Code Snippet....
#include <windows.h>
#include <dhcpsapi.h>

#pragma comment(lib, "Dhcpsapi.lib")

....

DWORD GetClientInfoByMAC(LPCTSTR pszDhcpServerIP, BYTE* pMac, DWORD
nMacLength, DHCP_CLIENT_INFO** ppInfo)
{
DHCP_SEARCH_INFO query;
query.SearchType = DhcpClientHardwareAddress;
query.SearchInfo.ClientHardwareAddress.DataLength = nMacLength;
query.SearchInfo.ClientHardwareAddress.Data = pMac;
return DhcpGetClientInfo(pszDhcpServerIP, &query, ppInfo);
}

....

BYTE Mac[11] = {0};
//Subnet address in host order. (192.168.1.0)
Mac[0] = 0;
Mac[1] = 1;
Mac[2] = 168;
Mac[3] = 192;
//Hardware address type, this is the default value.
Mac[4] = 0x01;
//My MAC bytes start from here (00:15:60:b0:2d:da)
Mac[5] = 0x00;
Mac[6] = 0x15;
Mac[7] = 0x60;
Mac[8] = 0xb0;
Mac[9] = 0x2d;
Mac[10] =0xda;

DHCP_CLIENT_INFO* pCI_MAC = {0};
DWORD nError = GetClientInfoByMAC(_T("192.168.1.10"), Mac, sizeof(Mac),
&pCI_MAC);
if(nError == ERROR_SUCCESS)
{
//IT WORKS!!!
...
}
else
{
//ERROR!!!
...
}
 
V

VladZ

My Vista gets IP from DHCP very well. And "The DhcpGetClientInfo function
returns information about a specific DHCP client..." (see DHCP API).
Code sample from my first post for search information about client (not
about my computer!) using its MAC address.
 
Joined
May 25, 2012
Messages
1
Reaction score
0
Hi,

Yes I've been having this problem too, try using the following change to the DHCP_SEARCH_INFO struct.

It's not complete (i.e. I've dropped the other union members) but this will return the results correctly on 64bit platforms however then doesn't work on 32bit platforms.

Perhaps the ClientIpAddress property is actually a pointer (hence why it changes with the platform?)

I'll see if I can solve this properly...


///<summary>
/// The DHCP_SEARCH_INFO structure defines the DHCP client record data used to search against for particular server operations.
///</summary>
///<remarks>http://msdn.microsoft.com/en-us/library/windows/desktop/aa363370(v=vs.85).aspx</remarks>
[StructLayout(LayoutKind.Sequential)]
private struct DHCP_SEARCH_INFO
{


///<summary>
/// Search type (IP, MAC, or Hostname)
///</summary>
public DHCP_SEARCH_INFO_TYPE SearchType;


///<summary>
/// The IP address
///</summary>
public ulong ClientIpAddress;

}




Thanks,


Dave
http://www.centrel-solutions.com/xiaconfiguration
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top