PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

DhcpGetClientInfo and Error 1783 in Vista

 
 
VladZ
Guest
Posts: n/a
 
      2nd Sep 2008
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!!!
...
}

----------------------
Thanks,
Vlad

 
Reply With Quote
 
 
 
 
Jack \(MVP-Networking\).
Guest
Posts: n/a
 
      2nd Sep 2008
Hi
Maybe this can Help, http://support.microsoft.com/kb/928233
Jack (MS, MVP-Networking)

"VladZ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!!!
> ...
> }
>
> ----------------------
> Thanks,
> Vlad
>


 
Reply With Quote
 
 
 
 
VladZ
Guest
Posts: n/a
 
      2nd Sep 2008
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.

--
Vlad


"Jack (MVP-Networking)." wrote:

> Hi
> Maybe this can Help, http://support.microsoft.com/kb/928233
> Jack (MS, MVP-Networking)
>
> "VladZ" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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?
> >


 
Reply With Quote
 
New Member
Join Date: May 2012
Posts: 1
 
      25th May 2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Vista Home Premium SVC PK 1 had error installing dazzle dvc100 driver from dazzle's pinnacle instant dvd recorder version 2.0 for Windows Vista 32bit 06/07 on my Windows Vista 32bit PC Colin Barnhorst Windows Vista Hardware 0 3rd Jul 2008 03:51 AM
BUG:Error 1783 (RPC_X_BAD_STUB_DATA)" when using QueryServiceConfi =?Utf-8?B?bGFuY2Vsb3Q1OQ==?= Windows XP General 0 22nd May 2007 01:06 PM
Vista Vista and more Vista Innes Windows Vista General Discussion 18 19th Feb 2007 04:19 AM
Comparison screen shots of Vista & Vista & Vista & Vista muckshifter Windows Vista 1 23rd Sep 2006 01:20 PM
Is DhcpGetClientInfo case sensitive? Russell Mellon Microsoft Windows 2000 Networking 0 28th Sep 2005 08:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:54 AM.