[Tutor] Alternate credentials
Tim Golden
mail at timgolden.me.uk
Wed May 4 09:57:15 CEST 2011
On 04/05/2011 00:18, Alan Gauld wrote:
> Since its more a Windows question than a Python one I suggest you try a
> Windows forum. comp.python.windows might be worth a try? Or even the
> ctypes group?
>
> While we do have some Windows users here its not really a python nwewbie
> type question.
True enough. I should be able to help nonetheless; but I would second
the recommendation to post this kind of question to the python-win32
mailing list:
http://mail.python.org/mailman/listinfo/python-win32
where you'll get the benefit of a lot more knowledge and experience
in the Windows area.
You could obviously achieve this *outside* Python -- ie by using
RunAs to launch a process as a different user. This may or may not
suit your case. If you want to do the switch from within the Python
process, you'll need to use the LogonUser [1] and
ImpersonateLoggedOnUser [2] APIs which are both available in the
pywin32 win32security module.
If you only want to make a connection under this alternative identity
(and not to do anything locally) then you could connect transiently
with specific credentials. To do this you'd use the WNetAddConnection
family of APIs [3].
Feel free to come back (or post to the python-win32 list) for more
information
TJG
[1] http://msdn.microsoft.com/en-us/library/aa378184%28v=vs.85%29.aspx
[2] http://msdn.microsoft.com/en-us/library/aa378612%28v=vs.85%29.aspx
[3] http://msdn.microsoft.com/en-us/library/aa385418%28v=vs.85%29.aspx
More information about the Tutor
mailing list