Showing posts with label ADSI. Show all posts
Showing posts with label ADSI. Show all posts
Friday, July 27, 2007
Tuesday, March 20, 2007
Programmatic IIS Administration - Selecting a Virtual Directory
This is a followup to an earlier post, Selecting a Site. The following function will return a virtual directory object, which you can then manipulate (set Directory Security options, ASP.NET version, etc.)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This sub will pass back a VirtualDirectory from a given Website Name, Virtual Directory Child 'Name
' Paramters: WebSite = Website Name
' VirDirName = Virtual Directory Name
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function GetVirtualDirectory(WebSite,VirDirName)
dim adspath,rootobj,WebSiteObj
set WebSiteObj=GetWebSiteByName(WebSite)
set rootObj=getObject(WebSiteObj.adsPath&"/root")
adspath=rootobj.adspath
set GetVirtualDirectory=getObject(adspath&"/"&VirDirName)
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This sub will pass back a VirtualDirectory from a given Website Name, Virtual Directory Child 'Name
' Paramters: WebSite = Website Name
' VirDirName = Virtual Directory Name
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function GetVirtualDirectory(WebSite,VirDirName)
dim adspath,rootobj,WebSiteObj
set WebSiteObj=GetWebSiteByName(WebSite)
set rootObj=getObject(WebSiteObj.adsPath&"/root")
adspath=rootobj.adspath
set GetVirtualDirectory=getObject(adspath&"/"&VirDirName)
end function
Friday, March 16, 2007
Setting ASP.NET Version via Script
Say you have a web server running multiple versions of ASP.NET. Various applications, for better or for worse, depend on a specific version of ASP.NET (e.g. it works under 1.1; throws errors under 2.0).
Here is a function for setting the version using ADSI automation:
Code snippet moved to a dedicated blog for readability
Here is a function for setting the version using ADSI automation:
Code snippet moved to a dedicated blog for readability
Wednesday, March 14, 2007
Programmatic IIS Administration - Selecting a Site
Configuring a web server can be complicated, particularly if it is running multiple web sites, with multiple virtual directories under each site. Such a complex IIS tree requires many, many mouse clicks in order to configure according to specifications.
And what happens if the server catches on fire? It may be a good idea to script the configuration. VBScript and the IIS ADSI objects offer a multitude of possibilities.
Here is a simple VBscript function for selecting a site by name (which you can then configure with proper directory security, isolation level, host headers, etc...)
Function GetWebSiteByName(WebSiteName)
dim rootObj,count,website
set rootObj=GetObject("IIS://LocalHost/W3SVC")
for each website in rootObj
if LCase(website.class) = LCase("IIsWebServer") then
if LCase(website.ServerComment)=LCase(WebSiteName) then
set GetWebSiteByName=website
exit function
end if
end if
next
end Function
Refer back for more Automated IIS Administration examples, using low-tech script :)
And what happens if the server catches on fire? It may be a good idea to script the configuration. VBScript and the IIS ADSI objects offer a multitude of possibilities.
Here is a simple VBscript function for selecting a site by name (which you can then configure with proper directory security, isolation level, host headers, etc...)
Function GetWebSiteByName(WebSiteName)
dim rootObj,count,website
set rootObj=GetObject("IIS://LocalHost/W3SVC")
for each website in rootObj
if LCase(website.class) = LCase("IIsWebServer") then
if LCase(website.ServerComment)=LCase(WebSiteName) then
set GetWebSiteByName=website
exit function
end if
end if
next
end Function
Refer back for more Automated IIS Administration examples, using low-tech script :)
Subscribe to:
Posts (Atom)