Re: Connecting to a File Server

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks Paul, but I confirmed by lookin directly in the registry using
RemoteRegistry tool.

"Paul G. Tobey [eMVP]" wrote:

You're sure? Check reginit.ini and make sure it ended up in the final
registry, just for grins. And, I guess you should be sure that the registry
is persisting.

Other than that, I'm out of my league. MasterKeysInRegistry is all I've
ever have to do to keep the connections persistent. You can use
GoogleGroups to search the Windows CE groups for other messages on the
topic.

Paul T.

"Vinz" <Vinz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F7AAFE09-2193-4F79-8F64-B11B6F982863@xxxxxxxxxxxxxxxx
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 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: GW loses more credibility (again)
    ... Paul, I never claimed any credentials other than I can read, and I ... I very much dispute that. ... What do you define as "basic" science? ...
    (alt.smokers.cigars)
  • Re: Saving Objectstore to a WinCE OS device
    ... As Paul pointed out, you need to provide a liitle more detail for us to ... persistent filesystem, any persistent filesystem, as the root of the ... have to worry about files going away when power is removed. ... registry andobjectstoreon system power down. ...
    (microsoft.public.windowsce.embedded)
  • Re: GW loses more credibility (again)
    ... Paul, I never claimed any credentials other than I can read, and I ... You really must stop making these global statements. ... disagrees with your preconceived opinions is automatically in the pay ...
    (alt.smokers.cigars)
  • Re: GW loses more credibility (again)
    ... Paul, I never claimed any credentials other than I can read, and I ... understand basic science. ... I very much dispute that. ...
    (alt.smokers.cigars)