win32 all question, win32security, impersonation
Mark Hammond
mhammond at skippinet.com.au
Thu May 23 02:41:30 EDT 2002
Syver Enstad wrote:
> I was fiddling around with mount points on win2k (using windll) the
> other day, and discovered that I had to be administrator to delete
The next version of win32file has support for this ;)
> mount points but only a super user to create them. Anyway, for fun I
> decided to check out the win32 api on how to logon as a different user
> while executing a program, I checked out the overview section on
> impersonation in the win32 all documentation, and it said that I had
> to obtain some privileges to be able to call the LogonUser function
> with any luck. I then proceeded to obtain the necessary privileges in
> my program using the sample code from the book *Python Programming on
> win32* by Hammond and Robinson. I succeed in obtaining one of the
> necessary privileges but as soon as I add the remaining privilges, the
> call to adjust privileges fail with:
>
> pywintypes.api_error: (1300, 'MyAdjustTokenPrivileges',
> 'Not all privileges referenced are assigned to the caller.')
MSDN documents that this error code may be returned from GetLastError(),
even when the function succeeds. It appears this error is informing you
that it didn't actually need to enable the privilege, or something like
that ;)
I have fixed win32security to ignore that error code (as many online C++
samples do) - you can always call GetLastError() yourself to get the
error code :) In the meantime you should be able to simply ignore the
exception if the error code portion is winerror.ERROR_NOT_ALL_ASSIGNED
Mark.
More information about the Python-list
mailing list