<% ' Copyright 2000-2001 IEA Software, Inc. ' Globals Dim Add ' 1=New Entry, 0=Update an existing entry Dim Armed ' True=Make Changes, False=Don't make changes ' Metabase objects Dim newserver Dim root Dim w3svc ' Variables sent from Emerald Dim IPAddress, Port, Hostname, Description, Path, AccountID, Active, AccountType AccountID = Request.Querystring("AccountID") Port = Request.Querystring("Port") IPAddress = Request.Querystring("IPAddress") Hostname = Request.Querystring("Hostname") Description = Request.Querystring("Description") Path = Request.Querystring("Path") Active = Request.Querystring("Active") AccountType = Request.Querystring("AccountType") Armed = True AccountID = AccountID + 1000000 ' Emerald variable validation If Path = "" THEN Err.Raise 17, "Home directory path is required" IF IPAddress = "" AND Port = "" AND Hostname = "" THEN Err.Raise 17, "At least one of IP Address, Port or Hostname are required" IF AccountID < 1000001 THEN Err.Raise 17,"AccountID is required" IF Port <> "" THEN IF Port <= 1 OR Port > 65534 THEN Port = 80 Else Port = 80 End If ' Open Metabase for web site Set w3svc = GetObject("IIS://localhost/w3svc") On Error Resume Next Err.Clear Set newserver = GetObject("IIS://localhost/w3svc/" & AccountID) if Err.Number <> 0 THEN On Error GoTo 0 If Active = 0 THEN Armed = False Add = True Set newserver = w3svc.Create("IIsWebServer",AccountID) Else On Error GoTo 0 Add = False End If If Armed = True THEN ' ---- Web Site Configuration ' http://msdn.microsoft.com/library/en-us/iisref/html/psdk/asp/aore7zn6.asp newserver.KeyType = "IISWebServer" newserver.ServerBindings = IPAddress & ":" & Port & ":" & Hostname newserver.ServerComment = Description newserver.DefaultDoc = "index.html,index.htm,default.htm" ' ---- ' Open Metabase for web site root directory If Add = True THEN Set root = newserver.Create("IIsWebVirtualDir","ROOT") Else Set root = GetObject("IIS://localhost/w3svc/" & AccountID & "/ROOT") End If ' ---- Root Directory Configuration ' http://msdn.microsoft.com/library/en-us/iisref/html/psdk/asp/aore8v5e.asp root.KeyType = "IISWebVirtualDir" root.Path = Path root.AccessRead = True root.setInfo root.AppCreate(True) ' ---- If (Active = 1) THEN newserver.ServerAutoStart = True newserver.SetInfo newserver.Start Else newserver.ServerAutoStart = False newserver.SetInfo newserver.Stop End If End If ' Don't do anything if site is not already created and account is inactive response.write("SetupOK") ' Returning anything else is concidered an error %>