Hi,
I have been trying to use the Impersonate user code that you have in
the PyWin32.chm document.
The code that I am trying is :
import win32security
import win32con
import win32api
class Impersonate:
def __init__(self,login,password):
self.domain='BLAHBLAH'
self.login=login
self.password=password
def logon(self):
self.handel=win32security.LogonUser
(self.login,self.domain,self.password,win32con.LOGON32_LOGON_INTERACTIVE,win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(self.handel)
def logoff(self):
win32security.RevertToSelf() #terminates impersonation
self.handel.Close() #guarantees cleanup
if __name__ == '__main__':
import os
import sys
sys.stdout.write ('Start process as ')
obj = Impersonate('another_user', '01928348')
obj.logon()
print win32api.GetUserName()
os.system('bash sleep.sh')
obj.logoff()
The sleep.sh this script uses has these commands "touch file1; sleep
300"
I am running this on Windows XP and with MKS toolkit installed on it
(so i can use 'bash', as in the code). I am currently logged in as
Vikas.
So when I see the task manager while the python script runs, the
sleep.sh is invoked as user 'Vikas' instead as 'another_user'.
And also the file that sleep.sh touches 'file1' has owner as 'Vikas'
instead of 'another_user'
So my query is that why is sleep.sh run as Vikas even though I
impersonate as 'another_user' ? Following the question, why is the
owner of file1 is 'Vikas' instead of 'another_user' ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---