Connecting to IIS 7.0 configuration remotely with Microsoft.Web.Administration

As you know, IIS 7.0 provides a number of ways to manage configuration other then MWA, including IIS Configuration COM objects for script, IIS Configuration COM objects from .NET or native clients, WMI, the IIS Manager tool (inetmgr.exe), and AppCmd. While all of these can be used to manage an IIS 7.0 box remotely (AppCmd with extra help of a remote shell environment or WMI), MWA remains one of the most common options because its so easily accessible from .NET.

Microsoft.Web.Administration uses the IIS 7.0 configuration objects under the covers, just like all of the other management options (except for IIS Manager, which uses the IIS Management service, and WMI, which uses the WMI DCOM remoting infrastructure).

Incidentally, this also means that Microsoft.Web.Administration can be used to remotely manage a Server Core installation.

This is despite the fact that currently Server Core does not support the .NET Framework - and is possible because MWA uses the IIS configuration COM objects as the underlying provider, which is native. So, while you cannot use MWA to manage a Server Core server locally, you can do it by running the .NET program remotely on a normal Windows Server 2008 or Windows Vista SP1 machine. However, you cannot use IIS Manager to manage a Server Core server remotely, because IIS Manager uses the IIS Management Service for remote management over HTTPS, which currently is not available on Server Core.

This brings us to the core of the issue: MWA uses the IIS configuration COM objects to manage the server, and therefore in the remote case requires DCOM access to the remote machine.

By default, DCOM access is blocked by Windows Firewall. Therefore, when you try to connect to a Windows Server 2008 or Windows Vista SP1 computer using Microsoft.Web.Administration, or another mechanism that also uses the IIS Configuration COM objects (everything except for WMI and IIS Manager), you will receive the RPC_S_SERVER_UNAVAILABLE error.

To enable DCOM access, you'll normally need to open TCP/135 for the DCOM port mapper, and the entire dynamic port range between 1024 and 65535 used by DCOM. Obviously, this is not something you want to do, especially not on a production server.

Luckily, DCOM provides a way to specify a fixed port for each COM+ package, which allows to enable remote configuration access by opening two ports:

  1. TCP 135 - DCOM port mapper
  2. A single TCP port for the IIS configuration COM objects

You can read more about this approach in Using Distributed COM with Firewalls.

------------------------------------------------------------------------------------

Go here to skip the reading, and grab the batch file to configure remote IIS config, and the RemoteConfigTest.exe tool to test IIS config connectivity.

------------------------------------------------------------------------------------

Here are the 3 steps to do it:

 

1) Configure the IIS configuration objects to use a fixed DCOM port

- Run dcomcnfg.exe
- Expand Component Services\Computers\My Computer\DCOM Config, select the “ahadmin” COM+ package
- Select Properties\Endpoints tab, click Add:
- Select “Connection-oriented TCP”
- Set fixed port

Dcomcnfg.exe:

DCOM configuration

Setting the endpoint configuration:

Setting a fixed DCOM endpoint

For command line usage, or if you are on server core, here is the equivalent:

> REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{9fa5c497-f46d-447f-8011-05d03d7d7ddc} /v EndPoints /d "ncacn_ip_tcp,0,<PORT>" /t REG_MULTI_SZ /f

(where <PORT> is the TCP port between 1024 and 65535 you'd like to dedicate to IIS config)

 

2) Open the required ports in the firewall

- Open TCP port 135 for the DCOM port mapper
- Open the selected TCP port

I additionally secure the opened ports as follows:

  1. Private profile only
  2. Set scope to “Local subnet” only, or specific computer addresses on the network
  3. Restrict ports to the process/services that provide DCOM access to the IIS config COM objects 

For command line usage, or if you are on server core, here are the commands:

> netsh advfirewall firewall add rule name="RPC Mapper" dir=in action=allow profile=private remoteip=localsubnet protocol=tcp localport=135 service=RpcSs

> netsh advfirewall firewall add rule name="AHADMIN Fixed Endpoint" dir=in action=allow profile=private remoteip=localsubnet protocol=tcp localport=<PORT> program=%windir%\system32\dllhost.exe

(where <PORT> is the fixed TCP port you chose in step 1)

You can also use ipsec to restrict access further.

 

3) Insure adequate access

You will need Administrative privileges on the remote machine in order to use IIS Configuration objects. This means that you either need to be logged in as/impersonating the local Administrator account with a syncronized password, or a domain account that has Administrative privileges on the remote server.

Due to UAC, you will not be able to use a local user other then BUILTIN\Administrator, even if that user is a member of the Administrators group on the remote machine (that is, unless you disable UAC).

There are additional things you can do by modifying activation ACLs on the COM+ package or DCOM security settings, but these are out of scope of this post.

4) Reboot 

I've seen cases where a reboot is required to pick up the DCOM changes.  Possibly because RpcSs caches the DCOM activation settings and therefore requires a reboot (its not possible to  restart RpcSs).

If you are unable to connect remotely after going through the steps above, be sure to reboot and try again.

Tools you can use: 

1) Batch file that will perform steps #1 and #2 for you:

> iisremoteconfig.bat 5000 - to setup IIS config access on port 5000

> iisremoteconfig.bat 0 - to remove the IIS config access

(NOTE: A reboot may be required to activate these settings)

2) The RemoteConfigTest.exe tool that will attempt a connection and diagnose the connectivity issues if any:

> RemoteConfigTest.exe 192.168.0.150

This tool will alert you if you have a firewall connectivity problem, forgot to register the IIS configuration COM objects, or do not have sufficient permissions to use them. 

Thanks,

Mike

 

 

Published 26 May 08 11:20 by Mike Volodarsky

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# IIS 7.0 Server-Side said on May 27, 2008 1:53 AM:

It&#39;s been one week since I left Microsoft, and what a week its been! I dont remember the last time

# RK said on May 27, 2008 10:44 PM:
Thanks for the tool!
# Web Hosting, French Way - by Laurent Bonnet [MS France] said on May 28, 2008 4:29 AM:

Mike Volodarsky , un de nos sp&#233;cialistes les plus productifs en mati&#232;re de communication sur

# MVolo's Blog said on May 28, 2008 1:47 PM:

IIS 7.0 provides a number of APIs that you can use to manage configuration remotely. This post provides

# amjadkhan said on June 2, 2008 4:29 AM:
Sent me deily newsletter plz
# mako said on June 17, 2008 2:59 AM:
Mike dot net framework is working on Server Core. This way http://dmitrysotnikov.wordpress.com/2008/05/15/powershell-on-server-core/ provides installing .net framework on Server Core. Note that these are in no way official or supported by Microsoft.
# Mike Volodarsky said on June 17, 2008 11:26 AM:

Mako,

Interesting post.  Unfortunately until this is supported officially via the new CLR designed for server core, its not a feasible production option for enterprises.

But, since you could use powershell and MWA against a server core server remotely, this limitation may not even matter in the real world. Of course, for individuals playing with server core, running management tasks locally is more of an issue ...

Thanks,

Mike

# Prabu Vontlin said on September 7, 2008 5:59 PM:
I have been working on IIS 7 and ASP.NET applicaton, that does provisioning (copied the code from litwarehr) in Windows 2008 Standard Server. I am running into a problem where when this code runs: private static string GetWebSiteNameById(ServerManager serverManager, long parentWebSiteId) { if (serverManager != null) { foreach (Site site in serverManager.Sites) { if (site.Id == parentWebSiteId) { return site.Name; } } } return String.Empty; } I get the exception: Retrieving the COM class factory for remote component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} from machine localhost failed due to the following error: 80070005. I tried searching in the internert and tried all different settings from disabling UAC, setting DCOM, firewall ports extra... nothing helps... I am testing locally on my localhost, the provisioning user is part of the administrator group. any help.. thanks in advance
# JOBBO said on June 1, 2009 2:52 AM:
Thanks for this tools Mike. But I have no luck to make it works. Here are some step I have done on Core WebServer. - I run command iisremoteconfig.bat 5000 , and then reboot server. - I run RemoteConfigTest.exe [ServerIP] from another computer, but it return this result IIS 7.0 Remote Config connectivity check by Mike Volodarsky More info: http://mvolo.com/blogs/serverside/archive/2008/05/26/Accessing-IIS-7. 0-configuration-remotely-and-on-server-core.aspx Connecting to web-core-server ... RPC_S_SERVER_UNAVAILABLE. Check network connectivity, insure RpcSs service start ed, open firewall settings to allow DCOM and Ahadmin remoting. - I check netstat on my WebServer Core, but it has no running services listening on port 7000. I think this is not the firewall issue. Could you help me on
# JOBBO said on June 1, 2009 4:17 AM:
Hi Mike. IIS7 Manager client installed on my Windows XP client. It always try to connect to webserver via port 8172. but on my webserver core was run iisremoteconfig.bat 7000. What should I do next.
# Mike Volodarsky said on June 4, 2009 11:38 PM:

Hi JOBBO,

IIS Manager uses the web management service to manage the server, it does not use MWA configuration remoting.  This article applies to configuring MWA remoting for connecting to remote configuration with MWA programs.

For configuring IIS Manager remoting, please see the appropriate content on iis.net.

Thanks,

Mike

Leave a Comment

(required) 
(optional)
(required) 
Enter the code you see below


About Mike Volodarsky

For the past 5 years, I was the core Program Manager for Microsoft ASP.NET 2.0 and IIS 7.0 products. I drove the design and development of the IIS 7.0 web server core, the IIS FastCGI support, the AppCmd command line tool, the ASP.NET Integrated pipeline, and other special projects around server security, performance, and scalability. Now, I am working on my own on cutting edge web server tech on top of the Microsoft IIS platform, and continue blogging about it here.

About me



For the past 5 years, I was the core server Program Manager for the IIS 7.0 and ASP.NET 2.0 products at Microsoft.
Now, I work on advanced web server tech using IIS 7.0, .NET, and Windows Server 2008 and write about it in this blog.

View Michael Volodarsky's profile on LinkedIn

Writings



TechNet Magazine
>Top 10 Performance Improvements in IIS 7.0

MSDN Magazine
>IIS 7.0: Build Web Server Solutions with End-To-End Extensibility
>IIS 7.0: Enhance Your Apps with the Integrated ASP.NET Pipeline
>IIS 7.0: Explore The Web Server For Windows Vista And Beyond
>Design and Deploy Secure Web Apps with ASP.NET 2.0 and IIS 6.0
>Fast, Scalable, and Secure Session State Management for Your Web Applications


Tools and Modules

LeechGuard
IconHandler 2.0
DirectoryListing
HttpRedirection
IIS Auth for Wordpress
iisschema.exe
PortCheck.exe v2.0

Popular Posts

- ASP.NET 2.0 Breaking Changes on IIS 7.0
- Develop IIS7 modules and handlers with .NET
- Troubleshoot IIS7 errors like a pro
- Troubleshooting 503 / "service unavailable" errors
- Troubleshooting "server not found" errors
- Create IIS7 sites, applications, and virtual directories
- Run Ruby on Rails with IIS FastCGI
- VS Debugging of ASP.NET applications on Windows Vista
- Stop hot-linking with IIS and ASP.NET

Tags

Search

Go

This Blog

Archives

Good IIS Blogs

Disclaimer

These postings are provided as is with no warranties, and confer no rights. The views expressed in this blog are entirely my own.

Syndication