?
Solved

Is there a way to add subdomains to IIS 6.0 programatically?

Posted on 2005-04-13
3
Medium Priority
?
961 Views
Last Modified: 2008-01-09
Hi,

I'll have to add about 150 subdomains to a top level domain. Before starting to do this manually I'd like to know if there's a way to do it programatically -> passing values and parameters from a SQL Server Database.

I was looking for examples on the internet but have nothing found yet.

Does anyone have an idea? Or some links that explain how to do this programatically?

VB6, VBScript, VB.NET or C# hints or examples are very much appreciated!


Best regards,
Raisor
0
Comment
Question by:Ralf Klatt
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
karlossos earned 2000 total points
ID: 13779992
This might help you out.

it goes through customizing deployment of apps on IIS.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchusingcustomactionstomodifyinternetinformationserverduringdeployment.asp

should allow you to automate the process with .NET and SQL.

hope this helps.
0
 
LVL 15

Author Comment

by:Ralf Klatt
ID: 13784628
Hi,

Thanks a lot for the provided link that is also giving some source code to understand the basics of doing what I'm up to do!

Another thing that the provided link did was to give me an understanding on what I'll have to look for to make things even easier than to go with VB.NET:

Public Overrides Sub Install(ByVal stateSaver As _
System.Collections.IDictionary)
    Dim strVDir As String = Me.Context.Parameters.Item("VDir")
    Dim intServerNum As Integer = _
    Me.FindServerNum(Me.Context.Parameters.Item("Port"))
    Dim strObjectPath As String = "IIS://" & _
    System.Environment.MachineName & "/W3SVC/" & _
    intServerNum.ToString & "/ROOT/" & strVDir
    Dim IISVdir As Object

    ' Gets the IIS VDir Object.
    IISVdir = GetIISObject(strObjectPath)

    ' Set the AuthAnonymous property here.
    IISVdir.AuthAnonymous = False

    ' Uses SetInfo to save the settings to the Server.
    IISVdir.SetInfo()
End Sub

What I found, using the information you've provided was infact a C#.NET approach that I'll try to leverage:

public class SetupUtility{public SetupUtility(){}public int CreateWebSite(string webSiteName, string pathToRoot){return CreateWebSite(webSiteName, pathToRoot, false);}public int CreateWebSite(string webSiteName, string pathToRoot, bool createDir){DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");// Find unused ID value for new web siteint siteID = 1;foreach(DirectoryEntry e in root.Children){if(e.SchemaClassName == "IIsWebServer"){int ID = Convert.ToInt32(e.Name);if(ID >= siteID){siteID = ID+1;}}}// Create web siteDirectoryEntry site = (DirectoryEntry)root.Invoke("Create", "IIsWebServer", siteID);site.Invoke("Put", "ServerComment", webSiteName);site.Invoke("Put", "KeyType", "IIsWebServer");site.Invoke("Put", "ServerBindings", ":80:");site.Invoke("Put", "ServerState", 2);site.Invoke("Put", "FrontPageWeb", 1);site.Invoke("Put", "DefaultDoc", "Default.aspx");site.Invoke("Put", "SecureBindings", ":443:");site.Invoke("Put", "ServerAutoStart", 1);site.Invoke("Put", "ServerSize", 1);site.Invoke("SetInfo");// Create application virtual directoryDirectoryEntry siteVDir = site.Children.Add("Root", "IISWebVirtualDir");siteVDir.Properties["AppIsolated"][0] = 2;siteVDir.Properties["Path"][0] = pathToRoot;siteVDir.Properties["AccessFlags"][0] = 513;siteVDir.Properties["FrontPageWeb"][0] = 1;siteVDir.Properties["AppRoot"][0] = "LM/W3SVC/"+siteID+"/Root";siteVDir.Properties["AppFriendlyName"][0] = "Root";siteVDir.CommitChanges();site.CommitChanges();return siteID;}}

... as soon as I have a "working" solution I'll share the peace of code that does what I'm up to do!

Thanks a lot for your help, karlossos ...


Best regards,
Raisor
0
 
LVL 15

Author Comment

by:Ralf Klatt
ID: 13784850
Hi,

Just an addon for anyone reading the C#.NET approach: I've found it at http://weblogs.asp.net/jezell/archive/2003/09/17/27869.aspx

... there are some useful diffs to the presented code there!


Best regards,
Raisor
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Six Sigma Control Plans
Introduction to Processes

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question