none
MprAdminUserSetInfo returns error code 1003 on Windows Server 2008 EE SP2 RRS feed

  • Question

  • On Windows Server 2003 R2 SE SP2 I am able to set Callback Options for a user on the Dial-in tab of the user's properties window via Computer Management/System Tools/Local Users and Groups/Users/user, for example "Always Callback to: 999999". I am also able to do this programmatically via the mprapi library call MprAdminUserSetInfo(), regardless of whether Routing and Remote Access has been set up or not.

    On Windows Server 2008 EE SP2 I am able to set Callback Options for a user on the Dial-in tab of the user's properties window via Server Manager/Configuration/Local Users and Groups/Users/user, for example "Always Callback to: 999999". However, I am *unable* to do this programmatically via the mprapi library call MprAdminUserSetInfo(), regardless of whether Routing and Remote Access has been set up or not.

    On 2008 the MprAdminUserSetInfo call returns the error code 1003, or "Cannot complete this function".

    Given that the same code works on WS 2003, and that the native Server Manager UI is able to set the callback number, I cannot understand why mprapi is returning a 1003 error code.

    Any help would be much appreicated!


    To run the code sample, just type: admapit.exe \\serverName userName

    Both my 2003 and 2008 servers were members of workgroups, not domains.


    On Windows 2003 I get:

    admapit.exe \\<serverName> Administrator
    Please specify the Client's phone number or IP address
    999999

    MprAdminUserGetInfo(\\garbe04-w2k3-im-sdk, Administrator): 0
    --PrintPriv--
    ppRasUser0->bfPrivilege = 0x2
                    RASPRIV_AdminSetCallback  = 0x2
                    Always callback to        = 555555
    -------------

    MprAdminUserSetInfo(\\garbe04-w2k3-im-sdk, Administrator): 0
    --PrintPriv--
    ppRasUser0->bfPrivilege = 0xa
                    RASPRIV_AdminSetCallback  = 0x2
                    Always callback to        = 999999
                    RASPRIV_DialinPrivilege   = 0x8
    -------------

    Showing that I successfully changed the dial-in callback number from 555555 to 999999 (add added DialinPrivilege).


    However, on Windows 2008 I get:

    admapit.exe \\<serverName> Administrator
    Please specify the Client's phone number or IP address
    999999

    MprAdminUserGetInfo(\\<serverName>, Administrator): 0
    --PrintPriv--
    ppRasUser0->bfPrivilege = 0x2
                    RASPRIV_AdminSetCallback  = 0x2
                    Always callback to        = 555555
    -------------

    MprAdminUserSetInfo(\\garbe04-w2k8-im, Administrator): 1003   <--------!!!
    ERROR  MprAdminUserSetInfo: Cannot complete this function.

    Parameters in:
            lpszServer=\\garbe04-w2k8-im
            lpszUser=Administrator
            dwLevel=0,
            lpbBuffer=
    --PrintPriv--
    ppRasUser0->bfPrivilege = 0xa
                    RASPRIV_AdminSetCallback  = 0x2
                    Always callback to        = ccc   <------ !!!
                    RASPRIV_DialinPrivilege   = 0x8
    -------------

    Note that the callback number buffer has been trashed by the failed MprAdminUserSetInfo call.


    I have built the following code (based on the SDK Samples\NetDs\RRas\Adminapi) using Visual Studio 9 using the v6.0a SDK for WS 2003 and using the v6.1 SDK for WS 2008.


    makefile

    ======

    !include <win32.mak>

    all: admapit.exe

    .c.obj:
      $(cc) $(cdebug) $(cflags) $(cvars) -DUNICODE $*.c

    admapit.exe: admapit.obj
        $(link) $(linkdebug) $(lflags) \
          $** -out:admapit.exe   \
          $(conlibs) shlwapi.lib mprapi.Lib user32.lib

    admapit.c

    ======

    #include <windows.h>

    #include <stdlib.h>
    #include <string.h>
    #include <stdarg.h>
    #include <lm.h>
    #include <stdio.h>
    #include <time.h>
    #include <ctype.h>
    #include <conio.h>
    #include <mprapi.h>
    #include <memory.h>

    #include <tchar.h>
    #include "Shlwapi.h" // Platform SDK wasn't including this .h file so it's part of this project
    #include "strsafe.h"

    //Function Definitions
    VOID UserPrivilege(VOID);
    VOID PrintPriv(WCHAR *DomainName, WCHAR *UserName);


    // Global Variables
    CHAR buf[120];
    WCHAR CallbackNumber[255];
    DWORD dwResult = 0;
    DWORD dwBytesWritten = 0;
    CHAR szBuf[120];
    PRAS_USER_0 ppRasUser0;
    RAS_USER_0 RasUser0;
    WCHAR lpszServerName[50];
    WCHAR RasSrv[64];
    WCHAR UserName[64];


    //
    // Function to print user privileges to logfile
    //
    VOID PrintPriv(WCHAR *DomainName, WCHAR *UserName)
    {
        DWORD dwBytesWritten = 0;

        /*********** from mprapi.h ****************************************************/
        //
        // Note: Bit 0 MUST represent NoCallback due to a quirk of the "userparms"
        //       storage method.  When a new LAN Manager user is created, bit 0 of the
        //       userparms field is set to 1 and all other bits are 0.  These bits are
        //       arranged so this "no Dial-In info" state maps to the "default Dial-In
        //       privilege" state.
        //
        // #define RASPRIV_NoCallback        0x01
        // #define RASPRIV_AdminSetCallback  0x02
        // #define RASPRIV_CallerSetCallback 0x04
        // #define RASPRIV_DialinPrivilege   0x08
        //
        // #define RASPRIV_CallbackType (RASPRIV_AdminSetCallback \
        //                             | RASPRIV_CallerSetCallback \
        //                             | RASPRIV_NoCallback)
        /*****************************************************************************/

        wprintf(L"--PrintPriv--\n");
        //wprintf(L"DomainName =  %ws\nUserName = %ws\n",DomainName, UserName);
        wprintf(L"ppRasUser0->bfPrivilege = 0x%x\n",ppRasUser0->bfPrivilege);
        if ((ppRasUser0->bfPrivilege) & (RASPRIV_NoCallback))
        {
            wprintf(L"\t\tRASPRIV_NoCallback        = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_NoCallback)));
        }
        if ((ppRasUser0->bfPrivilege) & (RASPRIV_AdminSetCallback))
        {
            wprintf(L"\t\tRASPRIV_AdminSetCallback  = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_AdminSetCallback)));
            wprintf(L"\t\tAlways callback to        = %ws\n", ppRasUser0->wszPhoneNumber);
        }
        if ((ppRasUser0->bfPrivilege) & (RASPRIV_CallerSetCallback))
        {
            wprintf(L"\t\tRASPRIV_CallerSetCallback = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_CallerSetCallback)));
        }
        if ((ppRasUser0->bfPrivilege) & (RASPRIV_DialinPrivilege))
        {
            wprintf(L"\t\tRASPRIV_DialinPrivilege   = 0x%x\n", (ppRasUser0->bfPrivilege & (RASPRIV_DialinPrivilege)));
        }
        wprintf(L"-------------\n");
    }


    //
    // Function to get and change User Dialin Privileges.
    // It goes through all the Dialin Privileges for a user.
    //
    VOID UserPrivilege()
    {
        DWORD dwResult;
        DWORD dwBytesWritten = 0;
        WCHAR Buf[512];
        WCHAR *lpszString;
        static BYTE Dialin = 0x2;
        lpszString = &Buf[0];
        ppRasUser0 = &RasUser0;

        dwResult = MprAdminUserGetInfo(RasSrv, UserName,(DWORD) 0, (LPBYTE) ppRasUser0);
        if (dwResult != NO_ERROR)
        {
            wprintf(L"ERROR MprAdminUserGetInfo     %d\n",dwResult);
            wprintf(L"Parameters in:\n\tlpszServer=%ws\n\tlpszUser=%ws\n\tdwLevel=0,\n\tlpbBuffer)\n", RasSrv, UserName);
            dwResult = MprAdminGetErrorString( dwResult, &lpszString);
            if (dwResult == NO_ERROR)
            {
                wprintf(L"ERROR  MprAdminUserGetInfo: %ws\n",lpszString);
            }
            else
            {
                wprintf(L"ERROR  MprAdminUserGetInfo: %d\n",dwResult);
            }
        }
        else //MprAdminUserGetInfo returned success
        {
            wprintf(L"\nMprAdminUserGetInfo(%ws, %ws): %d\n", RasSrv, UserName, dwResult);
            PrintPriv(RasSrv, UserName);
            ppRasUser0->bfPrivilege = (RASPRIV_DialinPrivilege | Dialin);
            wcscpy_s(ppRasUser0->wszPhoneNumber, sizeof(ppRasUser0->wszPhoneNumber)/sizeof(ppRasUser0->wszPhoneNumber[0]), CallbackNumber);
            dwResult = MprAdminUserSetInfo(RasSrv, UserName, 0, (LPBYTE)ppRasUser0);
            if (dwResult != NO_ERROR)
            {
                wprintf(L"\nMprAdminUserSetInfo(%ws, %ws): %d\n", RasSrv, UserName, dwResult);

                dwResult = MprAdminGetErrorString( dwResult, &lpszString);
                if (dwResult == ERROR_SUCCESS)
                {
                    wprintf(L"ERROR  MprAdminUserSetInfo: %ws\n",lpszString);
                }
                else
                {
                    wprintf(L"ERROR  MptAdminGetErrorString: %d\n", dwResult);
                }

                wprintf(L"Parameters in:\n\tlpszServer=%ws\n\tlpszUser=%ws\n\tdwLevel=0,\n\tlpbBuffer=\n", RasSrv, UserName);
                // dump this out to see what privileges were passed in UserSetInfo call
                PrintPriv(RasSrv, UserName);
            }
            else
            {
                wprintf(L"\nMprAdminUserSetInfo(%ws, %ws): %d\n", RasSrv, UserName, dwResult);
                MprAdminUserGetInfo(RasSrv, UserName,(DWORD) 0, (LPBYTE) ppRasUser0);
                PrintPriv(RasSrv, UserName);
            }
        }
    }  //end UserPrivilege()


    /*************************************************************************/
    /***************** Start Main ********************************************/
    /*************************************************************************/

    void _cdecl main(int argc, char **argv)
    {
        size_t rc;
        if (argc > 1)
        {
            mbstowcs_s(&rc, RasSrv, 64, argv[1], 32);
            mbstowcs_s(&rc, UserName, 64, argv[2], 32);
        }
        printf("Please specify the Client's phone number or IP address\n");
        wscanf_s(L"%254s", CallbackNumber, 255);

        UserPrivilege();
    } // Main End

    • Changed type bloodlust Tuesday, March 15, 2011 12:16 AM not answered
    Wednesday, March 9, 2011 12:21 AM