Welcome to weblogs.com.pk Sign in | Join | Help

Creating Web Site in IIS using ADSI

As posted earlier about ADSI; IIS also has an ADSI provider and one can use ADSI to manage IIS. Here is a simple script to create a new site; you can call it using

>iis-newsite.vbs SomeRandomNumber SomeUser Domain
>iis-newsite.vbs 8479 weblogs weblogs.com.pk

Const ADS_PROPERTY_UPDATE = 2
Const ServerName = "YourServerName"
dim NewServerBindings(2)
Set oArgs = WScript.Arguments
Set w3svc = GetObject("IIS://"+ServerName+"/w3svc")

userIndex = -1
userID = ""
userDomain = ""

userIndex = oArgs(0)
userID = oArgs(1)
userDomain = oArgs(2)

userIndex = 847900000 + userIndex

Set NewWebServer = w3svc.Create("IIsWebServer", userIndex)
NewWebServer.SetInfo
hostArray = Array(":80:" & userDomain, ":80:www." & userDomain)
NewWebServer.PutEx ADS_PROPERTY_UPDATE, "ServerBindings", hostArray
NewWebServer.SetInfo
NewWebServer.servercomment = userDomain
NewWebServer.SetInfo
Set NewDir = NewWebServer.Create("IIsWebVirtualDir", "ROOT")
NewDir.Path = "c:\inetpub\" + userID
NewDir.AccessRead = true
'Uncomment next lines to make this site with scripting support
'NewDir.AccessScript = true
'NewDir.AnonymousUserName = userID
'NewDir.AnonymousUserPass = userPassword
'NewDir.AnonymousPasswordSync = true
NewDir.AppCreate (True)
NewDir.AppFriendlyName = "Default Application"
NewDir.SetInfo

Published Friday, January 27, 2006 7:24 PM by khurram

Comments

No Comments

New Comments to this post are disabled