Re: Connecting to a File Server



It is already set to 1. Do you know if there is something else that I can do
to retreive a password and username saved in the credential manager?

"Paul G. Tobey [eMVP]" wrote:

Look up MasterKeysInRegistry in the help. It's a registry entry that tells
Windows CE how to save some items like passwords (in this case, you want it
to save them in the registry, which I presume is persistent).

Paul T.

"Vinz" <Vinz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9029963A-35A8-47D6-A233-F324DD2C5802@xxxxxxxxxxxxxxxx
Hi Everyone,

I'm migrating a device from Windows CE4.2 to 5.0. With the device we use a
command prompt program that allows a user to set a Network Share using
WNetAddConnection3. The point of the program is to be able to set a
username
and password and then add any number of network share (on the same domain)
and make them available after a reboot without having to enter the
passwork
each time.

Using 4.2 we were able to save the credentials and then pass 0 to username
and password parameters to WNetAddConnection3 and it worked. In the help
files (MSDN) it says that using 0 tells to the function to use default
username and passwork.

By using this method it give the possibility to the user to save a network
share and have it accessible after a reboot by using
CONNECT_UPDATE_PROFILE
with WNetAddConnection3(It was working perfectly under 4.2, maybe it's not
possible anymore under 5.0).

Under 5.0 it doesn't work anymore. I must add that our device is a
headless
device, that means that it's not possible for a dialog box to popup for
asking the user to enter the password. I suspect that the problem is with
the
save credential function. Here is the code, we call this code before
calling
WNetAddConnection3:

BOOL SaveDefaultCredentials(TCHAR *szUser, TCHAR *szPassword, TCHAR
*szUserFull, TCHAR *szDomain)
{
BOOL RetValue = FALSE;
CECREDENTIAL Credential;

Credential.Flags = 0;
Credential.Persist = CRED_PERSIST_LOCAL_MACHINE;
Credential.Type = CRED_TYPE_DOMAIN_PASSWORD;
Credential.UserName = szUserFull;
Credential.CredentialBlobSize = 0;
Credential.CredentialBlob = 0;

RetValue = CeCredWrite( 0, &Credential );
if (!RetValue)
{
wprintf(L"CeCredWrite error writing %s\r\n",Credential.UserName);
}
else
{
//wprintf(L"CeCredWrite success writing %s\r\n",
Credential.UserName);
}


// Set password
if( RetValue )
{
SEC_WINNT_AUTH_IDENTITY_W AuthIdentity;

AuthIdentity.User = szUser;
AuthIdentity.UserLength = wcslen(szUser);
AuthIdentity.Domain = szDomain;
AuthIdentity.DomainLength = wcslen(szDomain);
AuthIdentity.Password = szPassword;
AuthIdentity.PasswordLength = wcslen(szPassword);
AuthIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

RetValue = SaveSspCredentials(&AuthIdentity);
}
return RetValue;
}

BOOL SaveSspCredentials(SEC_WINNT_AUTH_IDENTITY_W *pAuthIdentity)
{
PWSTR Packages[] = {L"NTLM", L"KERBEROS"};
BOOL fRet = TRUE;
int i;

__try
{
for (i = 0; i < (sizeof(Packages) / sizeof(Packages[0])); i++)
{
CredHandle hCred; // Credential Handle
TimeStamp Lifetime;

if( AcquireCredentialsHandleW(
NULL, // Principal
Packages[i], // Names of the security packages
SECPKG_CRED_OUTBOUND,// Flag that indicates how these
credentials will be used
NULL, // LOGON id
pAuthIdentity,
NULL, // Pointer to a SEC_GET_KEY_FN
function
NULL, // get key arg
&hCred, // Pointer to CredHandle structure
that
receives the credential handle.
&Lifetime // Pointer to a TimeStamp
) == NO_ERROR )
{
FreeCredentialsHandle(&hCred);
}
}
}
__except(1)
{
fRet = FALSE;
wprintf(TEXT("AcquireCredentialsHandle faulted"));
}
return fRet;
}

Is this the correct way to do it in CE 5.0? I know that we should now use
CredWrite but CeCredWrite should be still supported.

Can somebody help me solve my problem?

Thanks



.



Relevant Pages

  • Re: Connecting to a File Server
    ... I'm migrating a device from Windows CE4.2 to 5.0. ... Using 4.2 we were able to save the credentials and then pass 0 to username ... BOOL SaveDefaultCredentials(TCHAR *szUser, TCHAR *szPassword, TCHAR ... BOOL RetValue = FALSE; ...
    (microsoft.public.windowsce.platbuilder)
  • Connecting to a File Server
    ... and password and then add any number of network share ... Using 4.2 we were able to save the credentials and then pass 0 to username ... BOOL SaveDefaultCredentials(TCHAR *szUser, TCHAR *szPassword, TCHAR ... BOOL RetValue = FALSE; ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Connecting to a File Server
    ... I guess you should be sure that the registry ... Using 4.2 we were able to save the credentials and then pass 0 to ... BOOL SaveDefaultCredentials(TCHAR *szUser, TCHAR *szPassword, TCHAR ... BOOL RetValue = FALSE; ...
    (microsoft.public.windowsce.platbuilder)
  • RE: Help Needed configuring Samba on Webserver
    ... username and password, and it reported successfully joining the domain ... Passwd: files windbind ... I logged in as the jkocher user on a windows xp pro station that is part ... Supplying the credentials for jkocher (the logged in ...
    (Fedora)
  • Re: Stange access problem
    ... Merv Porter [SBS-MVP] ... "Windows cannot bind to local domain (invalid credentials)" ... logging on with his correct username and password. ... One oddity is the username that pops up is not his 'domain/username'. ...
    (microsoft.public.backoffice.smallbiz)