Процедура разблокирования станции.

int WINAPI WlxWkstaLockedSAS( PVOID pWlxContext,DWORD dwSasType )
{
	LPGINA_CONTEXT		lpContext = (LPGINA_CONTEXT)pWlxContext;
	int					nResult = WLX_SAS_ACTION_NONE;
	CCredDlg*			lpDialog;
	int					nRes;
	HANDLE				hToken;
	BOOL				bRet;
	PTOKEN_USER			lpTokenLogon;
	PTOKEN_USER			lpTokenUnlock;
 	LPWSTR				wszUserName = NULL;
	LPWSTR				wszUserPassword = NULL;
	LPWSTR				wszUserDomain = NULL;
	lpDialog = new CCredDlg( lpContext );
	if( lpDialog != NULL )
	{
		nRes = lpDialog->ShowModal();
		if( nRes == WLX_DLG_SAS )
		{
			lpDialog->GetCredentials( wszUserName,wszUserDomain,wszUserPassword );
			wszUserName = DupString( wszUserName );
			wszUserPassword = DupString( wszUserPassword );
			wszUserDomain = DupString( wszUserDomain );
			bRet = ( DoLogon( wszUserName,wszUserDomain,wszUserPassword,&hToken,NULL,Unlock ) 
== STATUS_SUCCESS );
			FreeCredentials( wszUserName,wszUserDomain,wszUserPassword );
			if( bRet )
			{
				if( GetTokenUserInfo( lpContext->hUserToken,lpTokenLogon ) )
				{
					if( GetTokenUserInfo( hToken,lpTokenUnlock ) )
					{
						if( EqualSid( lpTokenLogon->User.Sid,lpTokenUnlock->User.Sid ) )
							nResult = WLX_SAS_ACTION_UNLOCK_WKSTA;
						else
						{
							if( IsMemberOfAdministrators( hToken ) )
							{
								if( ShowMessageW( lpContext,L»Do you wish
                                                                 to logoff?»,L»sGINA»,MB_YESNO ) == IDYES )
									nResult = WLX_SAS_ACTION_FORCE_LOGOFF;

							}
						}
						LocalFree( lpTokenUnlock );
					}
					LocalFree( lpTokenLogon );
				}
				CloseHandle( hToken );
			}
		}
		delete lpDialog;
	}
	return nResult;
}