Impersonate another user (Guest) on Windows

G

Giampaolo Rodola'

Hi,
I'm trying to write a plug-in for a ftp server of mine to permit the
integration with accounts defined on the Windows system.
What I basically need is impersonating a user, execute e filesystem
call (e.g. create a directory via os.mkdir()) and then switch back to
the original user (Administrator).
I wrote down this simple class which seems to fit pretty well for my
purposes:

class WinNTAuthorizer:

def impersonate_user(self, username, password):
self.impersonated_user_handler = win32security.LogonUser(
username,
None,
password,
win32con.LOGON32_LOGON_INTERACTIVE,
win32con.LOGON32_PROVIDER_DEFAULT)

win32security.ImpersonateLoggedOnUser(self.impersonated_user_handler)

def terminate_impersonation(self):
win32security.RevertToSelf()
self.impersonated_user_handler.Close()


What I need now is impersonating the Guest user to handle the
anonymous logins (which it's exactly what IIS FTPd does) but I don't
know how to do it.
Does Guest account has a password or do I have to use something
different than LogonUser to manage it?
Could someone point me in the right direction?

Thanks in advance.


--- Giampaolo
http://code.google.com/p/pyftpdlib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top