Win XP security question
Ive got a windows xp machine with two accounts, one administrator account and one restricted user account ("user"). I want to run a process that the user account cant terminate. Therefore I replaced the users shell with my own shell. The shell runs the application mentioned above with administrator privileges, the process is created with CreateProcessWithLogonW(). This process prevents the user from accessing the desktop, start menu and the like until the user identifies himself. After he has done that the process starts the explorer and maps a network drive. The process stays alive until the user shuts down the machine.
Now there are following issues:
(1) If I start the explorer from my shell, it inherits the calling process security attributes.
(2) If my shell maps the network drive, the mapping "belongs" to the Administrator (because the shell has Administrator privileges). Thus the mapping is invisible to the user account, because the user has only restricted privileges.
Issue (1) was solved by creating the explorer process with CreateProcessWithLogonW(), restricting the explorers security attributes.
Issue (2) is more complicated, I have to map the network drive in my shells process in the users security context. I tried the following code snippet (which didnt work):
CMyProcess::ConnectNetworkShare() {
HANDLE hUser;
// Obtain user handle
if( FALSE == ::LogonUser( "user", ".", "password", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUser ) ) {
AfxMessageBox( "Unable to log on user" );
return FALSE;
}
// Impersonate User
if( FALSE == ::ImpersonateLoggedOnUser( hUser ) ) {
// failure
AfxMessageBox( "Unable to impersonate user" );
::CloseHandle( hUser );
return FALSE;
}
// connect the network drive
if( NO_ERROR != ::WNetAddConnection2(...) ) {
// failure
AfxMessageBox( "Unable to connect network share" );
::CloseHandle( hUser );
return FALSE;
}
// revert to self
::RevertToSelf();
// close handle
::CloseHandle( hUser );
// report success
return TRUE;
The function returns TRUE when called, but there is no visible network mapping. Whats wrong with my code, did I miss something serious?
Thank you,
Guido
PS: For some really serious reasons I cant replace the gina dll to perform user identification. Please dont suggest replacing or modifying the default windows logon operation.

