Re: How Use LogonUser function In Gina ?

avdd_at_nanoteq.com
Date: 01/26/05


Date: 26 Jan 2005 05:05:49 -0800

I trust you have this one sorted out by now. The pWlxContext you
receive at WlxLoggedOutSAS is of the msgina format, which is
undocumented. You are now casting it to your own GINA_CONTEXT format.
You can't mix the 2 formats.

arith wrote:
> Please, Somebody help me after see following code .
> This code is in MSDN
> Why not working ?
>
> I wannar pass a Logon Dialog Box ( on window2000 ) using by LogonUser
> function.
> But i can't this, why ?
>
> Anwser for me.. please
>
> Thank U for reading .
>
> int
> WINAPI
> WlxLoggedOutSAS (PVOID pWlxContext,
> DWORD dwSasType,
> PLUID pAuthenticationId,
> PSID pLogonSid,
> PDWORD pdwOptions,
> PHANDLE phToken,
> PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
> PVOID * pProfile)
> {
>
> PGINA_CONTEXT pgContext = (PGINA_CONTEXT) pWlxContext;
> TOKEN_STATISTICS userStats;
> DWORD cbStats;
>
> if (!phToken)
> return WLX_SAS_ACTION_NONE;
>
> // Attempt to log on the user: guest, domain: earth
> // with password: secret.
>
> if (!LogonUser( "oz",
> "OZMA",
> "1111",
> LOGON32_LOGON_UNLOCK,
> LOGON32_PROVIDER_DEFAULT,
> phToken)){
> return WLX_SAS_ACTION_NONE;
> }
>
> // Check the user token.
> if (!(*phToken)) {
> return WLX_SAS_ACTION_NONE;
> }
>
> // Save the user token in the GINA context
> pgContext->UserToken =*phToken;
>
> // Pass back null profile and options.
> *pdwOptions = 0;
> *pProfile =NULL;
>
> // Get the authenticationid from the user token.
> if (!GetTokenInformation(*phToken,
> TokenStatistics,
> (PVOID) &userStats,
> sizeof(TOKEN_STATISTICS),
> &cbStats))
> {
> return WLX_SAS_ACTION_NONE;
> }
> else
> {
> *pAuthenticationId = userStats.AuthenticationId;
> }
>
> // Pass back multiple provider information.
>
> pMprNotifyInfo->pszUserName = DupString(L"oz");
> pMprNotifyInfo->pszDomain = DupString(L"OZMA");
> pMprNotifyInfo->pszPassword = DupString(L"1111");
> pMprNotifyInfo->pszOldPassword = NULL;
>
> return WLX_SAS_ACTION_LOGON;
> }
>
>
> BOOL
> WINAPI
> WlxActivateUserShell (PVOID pWlxContext,
> PWSTR pszDesktopName,
> PWSTR pszMprLogonScript,
> PVOID pEnvironment)
> {
> PGINA_CONTEXT pgContext = (PGINA_CONTEXT) pWlxContext;
> STARTUPINFO si;
> PROCESS_INFORMATION pi;
> BOOL bRet;
>
> // Setup STARTUPINFO to pass to CreateProcessAsUser.
> si.cb = sizeof(STARTUPINFO);
> si.lpReserved = NULL;
> si.lpTitle = L"userinit";
> si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
> si.dwFlags = 0;
> si.wShowWindow = SW_SHOW;
> si.lpReserved2 = NULL;
> si.cbReserved2 = 0;
> si.lpDesktop = pszDesktopName;
>
> // Determine and store the full path to userinit.exe in
> // the pszUserInitApp variable (not shown).
> // ...
> // Create the process for Userinit.exe.
> bRet = CreateProcessAsUser(pgContext->UserToken,
> pszUserInitApp,
> NULL, NULL, NULL, FALSE,
> CREATE_UNICODE_ENVIRONMENT,
> pEnvironment,
> NULL,
> &si,
> &pi );
>
> // Release the memory winlogon allocated for the environment.
> VirtualFree(pEnvironment, 0, MEM_RELEASE);
> return bRet;
>
> }