Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Add ServerBinding to IIS web site using Wscript

Posted on 2003-03-08
6
Medium Priority
?
626 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
  • 2
  • 2
4 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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Logparser is the smartest tool I have ever used in parsing IIS log files and there are many interesting things I wanted to share with everyone one of the  real-world  scenario from my current project. Let's get started with  scenario - How do w…
Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

578 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