How can I impersonate the current user with IronPython?
Question: 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.


Answer: (this doesn't necessarily answer the question but it does fix the problem)

It turned out my application worked fine. My setup was the problem. :(

To fix my issue I needed to:

  1. Log into the remote server.
  2. In IIS enable remote management (it's just a check box)
  3. In the Services snap-in, start the remote management service and set it to automatic

Thanks Anthony!

