Search code examples
authenticationpasswordswindows-ceplatform-builder

Issue with setting ADMIN password on Windows CE


I have wrote a user manager script the uses NTLMSetUserInfo to set passwords of some users, including ADMIN... What I have noticed though is that if I do this the username / password combination works perfectly for all scenarios such as Telnet, HTTP Auth etc but NOT file browsing.

Upon further inspection I noticed that when setting the Admin password through the built in CE configuration web pages it works.

The registry for Admin looks like so when I use NTLMSetUserInfo

NT = [hex value]

The registry for Admin contains an extra field, Password when I set the admin password via the CE web pages.

NT = [hex value]
Password = [hex value]

I figure NTLMSetUserInfo doesn't set the global CE password for Admin properly, hence not being able to file browse onto the box.

I found the following function in the CE web code parsing DLL that does the job called SetPassword. I wrote a separate function to deal with Admin cases but I cannot get it to compile. Here is a snippet of it

#include <windbase.h>

bool UserAccounts::SetAdminPassword(const std::string &passwordOld, const std::string &password)
{
    wchar_t wpass[512];
    wchar_t wpassold[512];

    mbstowcs(wpass, password.c_str(), 512);
    mbstowcs(wpassold, passwordOld.c_str(), 512);

    return SetPassword(wpassold, wpass) == TRUE;
}

This will not compile stating that 'SetPassword': identifier not found. I notice in the CE documentation for SetPassword it has the following line

To use this function, you must include the password component, Fspass, in your Cesysgen.bat file.

I'm not sure what this means as I am pretty new to PlatformBuilder etc...

Can anyone help me or point me in the right direction?


Solution

  • Add the following to the top of your code file:

    extern "C" BOOL SetPassword(LPWSTR lpszOldPassword, LPWSTR lpszNewPassword);
    

    The linker will do the rest.