[python-win32] Impersonation and Threads

Tim Roberts timr at probo.com
Wed Jan 9 00:17:55 CET 2008


Matt Herbert (matherbe) wrote:
>> -----Original Message-----
>> Tim Roberts wrote:
>>
>> Matt Herbert (matherbe) wrote:
>>     
>>> Is there a way to make impersonation follow threads?
>>>       
>> What operating system are you running?  On XP SP2 and later, a new 
>> thread should inherit the impersonation token of the calling thread, 
>> unless the caller passes a specific security descriptor into 
>> CreateThread.  (I don't know what the Python thread module 
>> does.)  On XP 
>> SP1 and before, you'd see the behavior you describe.
>>     
>
> I am running XP SP2. On my systems, the new thread definitely is not
> inheriting the impersonation token of the calling thread. For what it's
> worth, this is with Active State Python 2.5.
>
> Either way though, I need something that will work on XP, 2k, and 2k3.
>   

In that case, I think you will have to pass the token and call 
ImpersonateLoggedOnUser in each thread.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list