DhcpGetClientInfo and Error 1783 in Vista

Discussion in 'Windows Vista Networking' started by VladZ, Sep 2, 2008.

  1. VladZ

    VladZ Guest

    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
     
    VladZ, Sep 2, 2008
    #1
    1. Advertisements

  2. Hi
    Maybe this can Help, http://support.microsoft.com/kb/928233
    Jack (MS, MVP-Networking)

    "VladZ" <> wrote in message
    news:...
    > 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
    >
     
    Jack \(MVP-Networking\)., Sep 2, 2008
    #2
    1. Advertisements

  3. VladZ

    VladZ Guest

    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" <> wrote in message
    > news:...
    > > 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?
    > >
     
    VladZ, Sep 2, 2008
    #3
  4. VladZ

    DavidHomer

    Joined:
    May 25, 2012
    Messages:
    1
    Likes Received:
    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
     
    DavidHomer, May 25, 2012
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NLWard
    Replies:
    18
    Views:
    748
    Andre Da Costa [Extended64]
    May 25, 2006
  2. Robert L [MVP - Networking]

    Re: 0x80070035 Vista Ultimate and Vista Home Premium error

    Robert L [MVP - Networking], Apr 16, 2007, in forum: Windows Vista Networking
    Replies:
    0
    Views:
    1,107
    Robert L [MVP - Networking]
    Apr 16, 2007
  3. Guest
    Replies:
    4
    Views:
    277
    Guest
    May 2, 2007
  4. Doug

    New to vista - help pls with vista and xp network

    Doug, Jul 14, 2007, in forum: Windows Vista Networking
    Replies:
    2
    Views:
    136
    Guest
    Jul 14, 2007
  5. Jan
    Replies:
    0
    Views:
    186
Loading...

Share This Page