Hi,
<br> <p>I have been trying to use the Impersonate user code that you have in
<br> the PyWin32.chm document.
<br> The code that I am trying is :
<br> import win32security
<br> import win32con
<br> import win32api
<br> </p><p>class Impersonate:
<br> def __init__(self,login,password):
<br> self.domain='BLAHBLAH'
<br> self.login=login
<br> self.password=password
<br> def logon(self):
<br> self.handel=win32security.LogonUser
<br> (self.login,self.domain,self.password,win32con.LOGON32_LOGON_INTERACTIVE,win32con.LOGON32_PROVIDER_DEFAULT)
<br> win32security.ImpersonateLoggedOnUser(self.handel)
<br> def logoff(self):
<br> win32security.RevertToSelf() #terminates impersonation
<br> self.handel.Close() #guarantees cleanup
<br> </p><p>if __name__ == '__main__':
<br> import os
<br> import sys
<br> sys.stdout.write ('Start process as ')
<br> obj = Impersonate('another_user', '01928348')
<br> obj.logon()
<br> print win32api.GetUserName()
<br> os.system('bash sleep.sh')
<br> obj.logoff()
<br> </p><p>The sleep.sh this script uses has these commands "touch file1; sleep
<br> 300"
<br> </p><p>I am running this on Windows XP and with MKS toolkit installed on it
<br> (so i can use 'bash', as in the code). I am currently logged in as
<br> Vikas.
<br> </p><p>So when I see the task manager while the python script runs, the
<br> sleep.sh is invoked as user 'Vikas' instead as 'another_user'.
<br> And also the file that sleep.sh touches 'file1' has owner as 'Vikas'
<br> instead of 'another_user'
<br> </p>So my query is that why is sleep.sh run as Vikas even though I
<br> impersonate as 'another_user' ? Following the question, why is the
<br> owner of file1 is 'Vikas' instead of 'another_user' ?
<br clear="all"><br>-- <br>Vikas N V<br>mob: 9900107434<br>Visit my BLOG: <a href="http://techdiary-viki.blogspot.com/">http://techdiary-viki.blogspot.com/</a><br>