On 20/04/2010 15:39, le dahut wrote:
Hello, I'm trying to use "win32security.DuplicateTokenEx" but I encounter an error. My code looks like this : """ def getusertoken(): # process.get_pids(procname) returns a list of the pids of running copies of "<procname>" # for "winlogon" I suppose there is only one copy p = win32api.OpenProcess(1024, 0, process.get_pids('winlogon.exe')[0]) t = win32security.OpenProcessToken(p, win32security.TOKEN_DUPLICATE) return win32security.DuplicateTokenEx(t, win32con.MAXIMUM_ALLOWED, win32security.SECURITY_ATTRIBUTES(), win32security.SecurityIdentification, win32security.TokenPrimary ) """ The error is : TypeError: DuplicateTokenEx() argument 3 must be integer<k>, not PySECURITY_ATTRIBUTES MSDN says : BOOL WINAPI DuplicateTokenEx( __in HANDLE hExistingToken, __in DWORD dwDesiredAccess, __in_opt LPSECURITY_ATTRIBUTES lpTokenAttributes, __in SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, __in TOKEN_TYPE TokenType, __out PHANDLE phNewToken ); Is there is a problem with python implementation of "DuplicateTokenEx" or am I doing something wrong ?
Just glanced at the code. For some reason the Python function expects parameters in this order: ExistingToken PpyHANDLE) ImpersonationLevel (win32security.Security*) DesiredAccess (win32security.TOKEN_*) TokenType (TokenPrimary or TokenImpersonation) TokenAttributes (PySECURITY_ATTRIBUTES) Note that they can be supplied as keyword args with those names. TJG _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32