int WINAPI WlxLoggedOutSAS ( PVOID pWlxContext, DWORD dwSasType, PLUID pAuthenticationId, PSID pLogonSid, PDWORD pdwOptions, PHANDLE phToken, PWLX_MPR_NOTIFY_INFO pMprNotifyInfo, PVOID * pProfile) { if(MY_SAS_TYPE!=dwSasType) return WLX_SAS_ACTION_NONE;
PGINA_CONTEXT pgContext = (PGINA_CONTEXT) pWlxContext; int ret = pgContext->pWlxFuncs->WlxDialogBox(pgContext->hWlx, pgContext->hDllInstance, (LPWSTR)MAKEINTRESOURCE(IDD_INSERT_CARD_NOTICE_DIALOG), NULL, DisplaySASNoticeDlgProc ); if(ret==IDCANCEL) { return WLX_SAS_ACTION_SHUTDOWN; }
if (ret != IDC_LOGON_BUTTON) { return WLX_SAS_ACTION_NONE; }
TOKEN_STATISTICS userStats; TOKEN_GROUPS * pGroups; DWORD cbStats;
if (!phToken) return WLX_SAS_ACTION_NONE; while(1) {
if (!LogonUser(g_lpUserName, g_lpDomain, g_lpPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, phToken)) { //Logon failed. Give user a chance to update his disk
ret = pgContext->pWlxFuncs->WlxDialogBox(pgContext->hWlx, pgContext->hDllInstance, (LPWSTR)MAKEINTRESOURCE(IDD_WIN_LOGON_DIALOG), NULL, UpdateWindowsUserDlgProc );
if (ret != IDOK) { return WLX_SAS_ACTION_NONE; } } else break; }
pgContext->hUserToken=*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; }
DWORD size,i; pGroups = (TOKEN_GROUPS *)LocalAlloc(LMEM_FIXED, 1024); GetTokenInformation(*phToken, TokenGroups, pGroups, 1024, &size); if (size > 1024) { pGroups = (TOKEN_GROUPS *)LocalReAlloc(pGroups, LMEM_FIXED, size); GetTokenInformation(*phToken, TokenGroups, pGroups, size, &size); }
for (i = 0; i < pGroups->GroupCount ; i++) { if ((pGroups->Groups[i].Attributes & SE_GROUP_LOGON_ID) == SE_GROUP_LOGON_ID) { CopySid(GetLengthSid(pLogonSid), pLogonSid, pGroups->Groups[i].Sid ); break; } }
LocalFree(pGroups); pMprNotifyInfo->pszUserName=DupMbToWsString(g_lpUserName); pMprNotifyInfo->pszDomain=DupMbToWsString(g_lpDomain); pMprNotifyInfo->pszPassword=DupMbToWsString(g_lpPassword); pMprNotifyInfo->pszOldPassword = NULL; return WLX_SAS_ACTION_LOGON; }
|