?
Solved

Add ServerBinding to IIS web site using Wscript

Posted on 2003-03-08
6
Medium Priority
?
624 Views
Last Modified: 2007-12-19
I have now spent 5 hours trying to add extra ServerBindings to an existing IIS web site (Win2K Server, multiple sites, no Active Directory) using script. I can add the first one no problem, but when I try to add more I get all kinds of problems. After much searching I have discovered that I probably need to use the ADSI method PutEx, but it refuses to allow me to append - I can only update (which replaces all existing bindings). ADS_PROPERTY_APPEND and ADS_PROPERTY_DELETE are not listed in IISHELP but are detailed on MSDN. Does anybody know why or how to get round it?

const ADS_PROPERTY_CLEAR = 1
const ADS_PROPERTY_UPDATE = 2
const ADS_PROPERTY_APPEND = 3
const ADS_PROPERTY_DELETE = 4

Set NewWebServer = GetObject("IIS://ServerName/w3svc/1")
NewBindingsArray = Array(0)
NewBindingsArray(0) = ":80:www.domain.com"
NewWebServer.PutEx ADS_PROPERTY_APPEND, "ServerBindings", NewBindingsArray
NewWebServer.SetInfo
0
Comment
Question by:madlej
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 2

Expert Comment

by:Charlyoz
ID: 8137613
Try this: (It's a bit basic, but the functionality works.)

Dim IISOBJGlobal, LogLocation, GlobalDefDoc, GlobalScriptMaps
Dim IISOBJSiteCode, SiteCode, HostHeaders, SecureBind, ServerComm, SiteDefDoc
Dim IISOBJSiteRoot, SiteRoot
 
'Get WMI Object
Set IISOBJGlobal = GetObject("IIS://LocalHost/w3svc")
Set IISOBJSiteCode = GetObject("IIS://LocalHost/w3svc/1")
Set IISOBJSiteRoot = GetObject("IIS://LocalHost/w3svc/1/Root")
 
'Global
'Set Global Default Logging Location
LogLocation = "D:\Logfiles"
 
'Set Global Default Document
GlobalDefDoc = ""
 
'Set Global Script Mappings
GlobalScriptMaps=Array(".asp,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE",".cer,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE",".cdx,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE",".asa,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE")
 

'Set Server Comment Field
ServerComm = "SiteName Description"
 
'Set host header array
HostHeaders = Array("123.123.123.123:80:url.mydomain.com","123.123.123.123:80:url.mydomain.com","123.123.123.123:80:url.mydomain.com","123.123.123.123:80:url.mydomain.com")

'Set Secure Bindings array
SecureBind = Array("123.123.123.123:443:","123.123.123.123:443:","123.123.123.123:443:")
 
'Set Default Document for website
SiteDefDoc = ""
 
'Set Site Root Path
SiteRoot = "D:\Inetpub\wwwroot"
 
'Add all SiteCode entries to Metabase
'Global
IISOBJGlobal.LogFileDirectory=LogLocation
IISOBJGlobal.DefaultDoc=GlobalDefDoc
IISOBJGlobal.ScriptMaps=GlobalScriptMaps
IISOBJGlobal.SetInfo
'Site Specific
IISOBJSiteCode.ServerComment=ServerComm
IISOBJSiteCode.ServerBindings=HostHeaders
IISOBJSiteCode.SecureBindings=SecureBind
IISOBJSiteCode.DefaultDoc=SiteDefDoc
IISOBJSiteCode.SetInfo
'Site Root specific
IISOBJSiteRoot.Path=SiteRoot
IISOBJSiteRoot.SetInfo
0
 
LVL 2

Accepted Solution

by:
Charlyoz earned 200 total points
ID: 8137619
BTW. the text:

HostHeaders = Array("123.123.123.123:80:url.mydomain.

should all be on one line.
0
 

Author Comment

by:madlej
ID: 8138478
Sorry, my error. I was using the following line to make the bindings array:

   NewBindingsArray = Array(0)

This works fine for a one element array, however:

   NewBindingsArray = Array(2)

does not make an array with 3 elements. I just looked straight through this obvious error for hours. So in the end I didn't need to use PutEx, but simply:

   NewWebServer.ServerBindings = NewBindingsArray

Still don't know why PutEx append doesn't work though!
0
 

Author Comment

by:madlej
ID: 8138485
PS. thanks for the help.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Here are the symptoms: You start receiving calls from users that one of your legacy web apps isn't coming up, so you log into your IIS 5 server to check it out.  When you pull up the services, you notice that the WWW Publishing service isn't runn…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

800 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