WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Editing IIS Properties in 2003 SP1


Question:

Has anyone tried editing IIS properties in server 2003 SP1? After I install SP1, scripts fail with error 214, unable to set property. If I uninstall SP1 they work again. Even the example code from Article ID:W16330 does not work any more. Is there some security setting that has changed perhaps?

Here is the example code.

;******************************************************************************
; Program Information
;******************************************************************************
; CreateIISVirtualDir.wbt
; Created by Brad Sjue
; Date: August 20, 2003
; This script will create a Virtual Dir

;******************************************************************************
; Initialize Program
;******************************************************************************
AddExtender("WWADS34I.dll") ; ADSI Extender

;Optional Debugging
If IsKeyDown(@SHIFT || @CTRL)
sTrcFile = StrCat(Environment("TEMP"),"\~CMSWB.trc")
If FileExist(sTrcFile) Then FileDelete(sTrcFile)
DebugTrace(@ON,sTrcFile)
EndIf

CurrPath = FilePath(IntControl (1004, 0, 0, 0, 0))

;******************************************************************************
; Main Program
;******************************************************************************
:Begin
KeyToggleSet(@CAPSLOCK, @ON)
VirtualDir = AskLine ("Virtual Directory Creation", "Please enter the Virtual Directory Name (Virtual Directory without the underscore)", "")

NewDir = "C:\inetpub\wwwroot\\%VirtualDir%"
ChkDir = DirExist("C:\inetpub\wwwroot\\%VirtualDir%")
If ChkDir == @FALSE
Message("Nfuse Directory Error", "%VirtualDir% Directory Does not exist")
Goto Begin
EndIf

KeyToggleSet(@CAPSLOCK, @OFF)

If dsIsObject(StrCat("IIS://Localhost/W3SVC/1/ROOT/",VirtualDir))
dsDeleteObj(StrCat("IIS://Localhost/W3SVC/1/ROOT/",VirtualDir))
EndIf

NewObject = dsCreateObj("IIS://Localhost/W3SVC/1/ROOT","IIsWebVirtualDir",VirtualDir)

dsSetProperty(NewObject,"Path",NewDir) ; Path to directory
dsSetProperty(NewObject,"AccessFlags",513) ; Read and write access
dsSetProperty(NewObject,"AccessRead",-1) ; Read Access = TRUE
; dsSetProperty(NewObject,"AccessWrite",-1) ; Write Access = TRUE
; dsSetProperty(NewObject,"DontLog",0) ; DontLog = FALSE
dsSetProperty(NewObject,"AuthNTLM",0) ; No NTLM Authentication = FALSE
dsSetProperty(NewObject,"AppIsolated",2)
dsSetProperty(NewObject,"appFriendlyName",VirtualDir)
; dsSetProperty(NewObject,"AppCreate",0)
dsSetObj(NewObject)

Message("Complete", "Done")

;******************************************************************************
; End of Program
;******************************************************************************
Exit
Here is the trace file from the example code.
************************************************************

*** Debug Initialized ***

==============================
Thu 9/1/2005 1:51:02 PM
WinBatch 32 2005C
WIL DLL 5.7ceg
\\logosbuild\c$\code\Logos 4.1\Utilities\VirtualDir Tool\test.exe
Windows platform: NT, version: 5.2, build: 3790 (Service Pack 1)
ErrorMode: @CANCEL
==============================

CurrPath = FilePath(IntControl (1004, 0, 0, 0, 0))
(16) VALUE STRING => "\\logosbuild\c$\code\Logos 4.1\Utilities\VirtualDir Tool\"

KeyToggleSet(@CAPSLOCK, @ON)
(16) VALUE INT => 0

VirtualDir = AskLine ("Virtual Directory Creation", "Please enter the Virtual Directory Name (Virtual Directory without the underscore)", "")
(36266) VALUE STRING => "wbTESTapp"

NewDir = "C:\inetpub\wwwroot\\wbTESTapp"
(36266) VALUE STRING => "C:\inetpub\wwwroot\\wbTESTapp"

ChkDir = DirExist("C:\inetpub\wwwroot\\wbTESTapp")
(36266) VALUE INT => 1

If ChkDir == @FALSE
(36281) END OPERATOR

KeyToggleSet(@CAPSLOCK, @OFF)
(36344) VALUE INT => 1

if dsisObject(StrCat("IIS://Localhost/W3SVC/1/ROOT/",VirtualDir))
(36485) END OPERATOR

NewObject = dsCreateObj("IIS://Localhost/W3SVC/1/ROOT","IIsWebVirtualDir",VirtualDir)
(36516) VALUE STRING => "IIS://Localhost/W3SVC/1/ROOT/wbTESTapp"

dsSetProperty(NewObject,"Path",NewDir)
(42172) VALUE INT => 0

TERMINAL EXTENDER ERROR=>214 (214: Unable to set property value(s).)

;;;END OF JOB;;;

---------- Begin WWWBATCH.INI dump ----------
[Error Reporting]
3052=strcfile
[COM Sub-system]
Function=InvokeMember
ErrorCode=9 (0x80020009)
ErrorDesc=Exception occurred.
----------- End WWWBATCH.INI dump ----------- 

Answer:

I have not been able to find any information on what changes have been made in Win2k3 SP1 that are causing ADSI to have fits. But I was able to get most of the functionality you want using IIS administrative objects. Here is an example (note that the commented out properties could not be set.)
; Create the vdir
objIIS  = GetObject("IIS://localhost")
objVdir = objIIS.Create("IIsWebVirtualDir" , "W3SVC/1/Root/TEST")
objVdir.SetInfo

; Add properties
objVdir.Path = "C:\Inetpub\wwwroot\Test"
;objVdir.AccessFlag = 513 ; Read and write access
objVdir.AccessRead = -1  ; Read Access = TRUE
objVdir.AccessWrite = -1 ; Write Access = TRUE
objVdir.AuthNTLM = 0     ; No NTLM Authentication = FALSE
objVdir.AppIsolated = 2
objVdir.appFriendlyName = "W3SVC/1/Root/TEST"
;objVdir.AppCreate = 0
objVdir.SetInfo

Message("Success", "!")

objVdir = 0
objIIS  = 0
Out of curiosity which IIS technology/ies are you using in C#: IIS admin objects, IIS ADSI provider and/or IIS WMI provider?

Note that you can use IIS admin objects to get the job done in WB.

Another Users Reply:

This works for me with 2003 SP1. Note: I had to change the site to use w3svc whereas before I did not have to do that I don't think.
Client = "MySite"
ClientWIDir="C:\Inetpub\wwwroot\test2"
AppName= "MySite"
AppPoolName= "DefaultAppPool"
ThisSite = "IIS://localhost/w3svc/1/ROOT"
NewWebServer = ObjectGet(ThisSite)
NewDir = NewWebServer.Create("IIsWebVirtualDir", Client)
NewDir.Path = ClientWIDir
NewDir.SetInfo
NewDir.AppCreate (@TRUE)
NewDir.AppFriendlyName=AppName
NewDir.AppPoolId=AppPoolName
NewDir.AppIsolated=2
NewDir.Authanonymous=@TRUE
NewDir.AuthBasic=@FALSE
NewDir.AuthNTLM=@TRUE
NewDir.AccessSSL=@FALSE
NewDir.AccessSSLNegotiateCert=@FALSE
NewDir.AccessSSLRequireCert=@FALSE
NewDir.AccessSSLMapCert=@FALSE
NewDir.AspEnableParentPaths=@FALSE
NewDir.AccessRead = @TRUE
NewDir.AccessFlags=1
NewDir.SetInfo
NewWebServer = "" ;Closes the object
NewDir = "" ;Closes the object

Answer:

This is what I have found too. IIS administrative objects appear to work with Win2k sp1 but MFST's IIS ADSI extension does not. The developers report that there appears to be a bug in the latest versions of the Windows adsiis.dll (both Win2k3 sp1 and WinXP sp2) that is encountered when the extender calls the IADsPropertyList interface to access IIS properties. Using COM automation (GetObject) to access IIS properties does not encounter this bug because a different interface is used to supply values to automation clients.

The extender is taking all the necessary steps to verify that the interface in question is supported by the object before it attempts to obtain property values and the IIS admin object is reporting back that it supports the interface. I don't think there is any reasonable modification that can be made to the extender to workaround this problem. My best advice is to covert your programs to straight COM.


Article ID:   W16802
File Created: 2007:07:03:14:26:18
Last Updated: 2007:07:03:14:26:18