How can I impersonate the current user with IronPython?

Posted by Ryan Montgomery on Stack Overflow See other posts from Stack Overflow or by Ryan Montgomery
Published on 2009-09-01T14:33:55Z Indexed on 2010/05/22 8:20 UTC
Read the original article Hit count: 222

Filed under:
|

I am trying to manage an IIS7 installation remotely using the Microsoft.Web.Administration library.

I'm doing this in IronPython:

import Microsoft.Web.Administration
from Microsoft.Web.Administration import ServerManager

manager = ServerManager.OpenRemote("RemoteServerName")
for site in manager.Sites:
     print "Site: %(site)s" % { 'site' : site.Name }

On the last line as it attempts to communicate with the remote server I get the following error:

Retrieving the COM class factory for remote component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} from machine devdealernetsvr failed due to the following error: 80070005.

My research into the error lead me to believe that I do not have the proper credentials against the remote machine and so I would like to impersonate a user that does.

I was hard pressed to find a way to do this with IronPython. Any help is much appreciated.

© Stack Overflow or respective owner

Related posts about ironpython

Related posts about iis7