views:

87

answers:

1

I'd like to add Host Headers to an IIS from PHP. Is there a way to access the metabase from PHP or do I have to write a .NET command line tool and then invoke it from PHP?

Here's the background for the question. I have a Wordpress MU installation on Windows 2003/IIS6. The only way the setup will support subdomains (blog.mainsite.com) is by adding each subdomain to the site's Host Headers setting. Doing this manually every time a new subdomain is created is tedious and error prone, so I'm looking for a way to have it done through code.

A: 

I've been down this road with PHP in the past and eventually ended up shelling out to either VB script or .NET console apps.

David Wang has a handy script that allows you to add/remove new host headers individually (which you can't do using adsutil.vbs).

How to manipulate (insert/replace/remove) list data type in IIS configuration (David Wang)

Kev
Thanks much! Will check it out shortly
kalengi
@kalengi - you should note that the user account running this script will need to be an administrator.
Kev
Figured as much. One question though, doesn't this introduce a potential security problem due to the fact that altering web server state (an admin function) is being done through user pages that could be compromised?
kalengi
@kalengi - ideally you would sandbox that code separately from end user code. I'm presuming you have a separate WordPress admin site for this feature?
Kev
hey @Kev! I saw your comment (http://blog.stackoverflow.com/2010/10/asking-better-questions/#comment-50973) and remembered you'd addressed this question. I eventually did a WordPress plugin for this that calls a c# console program to add the host-header. The C# program requires considerable rights for this to work including modifying the IIS metabase to allow the programatic modification. Thanks for pointing me in the right direction :)
kalengi
@kalengi - glad I could help :)
Kev