Configuring FPSE Programatically
Recently I wrote a script that is used to create bulk users on a Server 2003 terminal server. The script creates the user, places them in proper Active Directory OU, and adds them to the proper groups, pretty simple.
Well in order to allow the users to develop and debug ASP.NET web applications I also had to set the server up so that they each had their own subweb and application pool. I also additionally had to create a tool that would sychronize their application pool and subweb user's password when they made a change.
The last and final hurdle I had to jump over was actually configuring FrontPage Server Extensions for each of the subwebs. As far as I can tell there are no APIs or easy ways to do this with Server 2003 and IIS 6.0 out of the box. After googling for a while, I did find a tool that would help, but could not actually locate the tool, so I decided to give up and came up with this solution instead:
public static void EnableFrontPageExtensions(string server, string web, bool inherit, string domain, string username)
{
StringBuilder sb = new StringBuilder();
sb.Append("web=%2F");
sb.Append(web);
sb.Append("&operation=create&page=newsbweb.htm&nextpage=webadmin.htm&oweb=&uweb=");
sb.Append(web);
if (inherit)
sb.Append("&Inherit=true");
else
{
sb.Append("&Inherit=false&username=");
sb.Append(domain);
sb.Append("%5C");
sb.Append(username);
}
sb.Append("&siteprovision=publish&Submit=++Submit++");
byte[] data = new ASCIIEncoding().GetBytes(sb.ToString());
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(server + "/_vti_bin/_vti_adm/fpadmdll.dll");
req.Credentials = CredentialCache.DefaultCredentials;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
Stream stream = req.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
req.GetResponse();
}