Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

GetObject - Changing Web Site Settings

 
   Web Hosting Problem Solving Community! (Home) -> IIS RSS
Next:  Black and White Film, Black and White Regime  
Author Message
Phil Dowson

External


Since: Jan 17, 2006
Posts: 2



(Msg. 1) Posted: Tue Jan 17, 2006 1:47 pm
Post subject: GetObject - Changing Web Site Settings
Archived from groups: microsoft>public>inetserver>iis (more info?)

Hi,

I am trying to set some settings for a Web Site that I had just created
using an ASP script created by Tim Huckaby, whic was derived from
MkW3Site.VBS. The site is created exactly as it is desired except that
nothing is set correctly in the Application Settings section of the web
site's properties. The application name is blank (rather than greyed),
the starting point is correct but the Execute permissions are none.

I thought that I had set the permissions to be Scripts Only in my
script (ASP) but it looks like the Application is not being created.
Can someone tell me why the application is not being created and
perhaps how I can tweak my script to create (or at least set the
parameters) of the Application. [code below]

Please help!

Phil

[code]
Set oWebService = GetObject("IIS://localhost/W3SVC/123456789")
oWebService.LogExtFileDate = True
oWebService.LogExtFileHost = True
oWebService.LogExtFileTime = True
oWebService.LogExtFileClientIp = True
oWebService.LogExtFileUserName = True
oWebService.LogExtFileSiteName = True
oWebService.LogExtFileComputerName = True
oWebService.LogExtFileServerIp = True
oWebService.LogExtFileMethod = True
oWebService.LogExtFileUriStem = True
oWebService.LogExtFileUriQuery = True
oWebService.LogExtFileHttpStatus = True
oWebService.LogExtFileWin32Status = True
oWebService.LogExtFileBytesSent = True
oWebService.LogExtFileBytesRecv = True
oWebService.LogExtFileTimeTaken = True
oWebService.LogExtFileServerPort = True
oWebService.LogExtFileUserAgent = True
oWebService.LogExtFileCookie = True
oWebService.LogExtFileReferer = True
oWebService.LogExtFileProtocolVersion = True
oWebService.LogExtFileHttpSubStatus = True
oWebService.LogFileDirectory = "D:\IISLogs\www"
oWebService.DefaultDoc = "index.asp"
oWebService.EnableDefaultDoc = True
oWebService.AccessScript = True
oWebService.AccessRead = True
oWebService.AppFriendlyName="Default Application"
oWebService.SetInfo
[/code]

 >> Stay informed about: GetObject - Changing Web Site Settings 
Back to top
Login to vote
Phil Dowson

External


Since: Jan 17, 2006
Posts: 2



(Msg. 2) Posted: Wed Jan 18, 2006 6:27 am
Post subject: Re: GetObject - Changing Web Site Settings [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Never mind, I have it worked out. My problem was that the Application
Name was only being set for the website but not for the Home
Directory/Virtual Server. For those interested in creating a website
via ASP here is my full code:

[code]
Dim ArgIPAddress, ArgRootDirectory, ArgServerComment, ArgSkeletalDir,
ArgHostName, ArgPort
Dim ArgStart
Dim ArgSiteNumber
Dim oArgs, ArgNum
Dim verbose

ArgComputers = Array(0)

ArgIPAddress = "192.168.1.1"
ArgPort = 80
ArgStart = False
ArgHostName = "www.domain.com"
ArgComputers(0) = "localhost"
ArgSiteNumber = "0"
ArgRootDirectory = "C:\Inetpub\wwwroot\www.domain.com"
ArgServerComment = "www.domain.com"
verbose = True

On Error Resume Next

Call ASTCreateWebSite(ArgIPAddress, ArgRootDirectory, ArgServerComment,
ArgHostName, ArgPort, ArgComputers, ArgStart)

Sub ASTCreateWebSite(IPAddress, RootDirectory, ServerComment, HostName,
PortNum, Computers, Start)
Dim w3svc, WebServer, NewWebServer, NewDir, Bindings, BindingString,
NewBindings, ComputerIndex, Index, SiteObj, bDone
Dim comp
On Error Resume Next

For ComputerIndex = 0 To UBound(Computers)
comp = Computers(ComputerIndex)
If ComputerIndex = UBound(Computers) Then
Trace "Creating web site on " & comp & "."
End If


Err.Clear
Set w3svc = GetObject("IIS://" & comp & "/w3svc")
If Err.Number <> 0 Then
Display "Unable to open: "&"IIS://" & comp & "/w3svc"
Else
Trace "Success in opening: "&"IIS://" & comp & "/w3svc"
End If

BindingString = IpAddress & ":" & PortNum & ":" & HostName
Trace "Making sure this web server doesn't conflict with another..."
For Each WebServer in w3svc
If WebServer.Class = "IIsWebServer" Then
Bindings = WebServer.ServerBindings
If BindingString = Bindings(0) Then
Trace "The server bindings you specified are duplicated in another
virtual web server."
Response.End
End If
End If
Next

Index = 1
bDone = False
Trace "Creating new web server..."

' If the user specified a SiteNumber, then use that. Otherwise,
' test successive numbers under w3svc until an unoccupied slot is
found
If ArgSiteNumber <> 0 Then
Set NewWebServer = w3svc.Create("IIsWebServer", ArgSiteNumber)
NewWebServer.SetInfo
If (Err.Number <> 0) Then
Response.Write "Couldn't create a web site with the specified
number: " & ArgSiteNumber
Response.End
Else
Err.Clear
' Verify that the newly created site can be retrieved
Set SiteObj = GetObject("IIS://"&comp&"/w3svc/" & ArgSiteNumber)
If (Err.Number = 0) Then
bDone = True
Trace "Web server created. Path is - "&"IIS://"&comp&"/w3svc/" &
ArgSiteNumber
Else
Response.Write "Couldn't create a web site with the specified
number: " & ArgSiteNumber
Response.End
End If
End If
Else
While (Not bDone)
Err.Clear
Set SiteObj = GetObject("IIS://"&comp&"/w3svc/" & Index)

If (Err.Number = 0) Then
' A web server is already defined at this position so increment
Index = Index + 1
Else
Err.Clear
Set NewWebServer = w3svc.Create("IIsWebServer", Index)
NewWebServer.SetInfo
If (Err.Number <> 0) Then
' If call to Create failed then try the next number
Index = Index + 1
Else
Err.Clear
' Verify that the newly created site can be retrieved
Set SiteObj = GetObject("IIS://"&comp&"/w3svc/" & Index)
If (Err.Number = 0) Then
bDone = True
Trace "Web server created. Path is - "&"IIS://"&comp&"/w3svc/" &
Index
Else
Index = Index + 1
End If
Err.Clear

If (bDone = True) Then
Set oWebService = GetObject("IIS://"&comp&"/W3SVC/" & Index)
If (Err.Number = 0) Then
oWebService.LogExtFileDate = True
oWebService.LogExtFileHost = True
oWebService.LogExtFileTime = True
oWebService.LogExtFileClientIp = True
oWebService.LogExtFileUserName = True
oWebService.LogExtFileSiteName = True
oWebService.LogExtFileComputerName = True
oWebService.LogExtFileServerIp = True
oWebService.LogExtFileMethod = True
oWebService.LogExtFileUriStem = True
oWebService.LogExtFileUriQuery = True
oWebService.LogExtFileHttpStatus = True
oWebService.LogExtFileWin32Status = True
oWebService.LogExtFileBytesSent = True
oWebService.LogExtFileBytesRecv = True
oWebService.LogExtFileTimeTaken = True
oWebService.LogExtFileServerPort = True
oWebService.LogExtFileUserAgent = True
oWebService.LogExtFileCookie = True
oWebService.LogExtFileReferer = True
oWebService.LogExtFileProtocolVersion = True
oWebService.LogExtFileHttpSubStatus = True
oWebService.LogFileDirectory = "D:\IISLogs\www"
oWebService.DefaultDoc = "index.asp"
oWebService.EnableDefaultDoc = True
oWebService.SetInfo
Trace "Web Server Parameters Set - "&"IIS://"&comp&"/w3svc/" &
Index
Else
Display "Unable to open: IIS://"&comp&"/W3SVC/" & Index
End If
Err.Clear


End If


End If
End If

' sanity check
If (Index > 10000) Then
Trace "Seem to be unable to create new web server. Server number
is "&Index&"."
Response.End
End If
Wend
End If

NewBindings = Array(0)
NewBindings(0) = BindingString
NewWebServer.ServerBindings = NewBindings
NewWebServer.ServerComment = ServerComment

NewWebServer.SetInfo

Trace "Setting the home directory..."
Set NewDir = NewWebServer.Create("IIsWebVirtualDir", "ROOT")
NewDir.Path = RootDirectory
NewDir.AccessRead = True

Err.Clear
NewDir.SetInfo
NewDir.AppCreate (True)

If (Err.Number = 0) Then
Trace "Home directory set."
Else
Display "Error setting home directory."
End If

If (bDone = True) Then
Set oWebService = GetObject("IIS://"&comp&"/W3SVC/" & Index &
"/root")
If (Err.Number = 0) Then
oWebService.AccessScript = True
oWebService.AccessRead = True
oWebService.AppFriendlyName="Default Application"
oWebService.SetInfo
Trace "Root Parameters Set - " & "IIS://"&comp&"/W3SVC/" & Index &
"/root"
Else
Display "Unable to open: IIS://"&comp&"/W3SVC/" & Index & "/root"
End If
Err.Clear
End If


Trace "Web site created!"
Next
End Sub

Sub Display(Msg)
Response.Write Now & ". Error Code: " & Hex(Err) & " - " & Msg &
"<br>"
End Sub

Sub Trace(Msg)
if verbose = True then
Response.Write Now & " : " & Msg & "<br>"
end if
End Sub
[/code]

Phil Dowson wrote:
> Hi,
>
> I am trying to set some settings for a Web Site that I had just created
> using an ASP script created by Tim Huckaby, whic was derived from
> MkW3Site.VBS. The site is created exactly as it is desired except that
> nothing is set correctly in the Application Settings section of the web
> site's properties. The application name is blank (rather than greyed),
> the starting point is correct but the Execute permissions are none.
>
> I thought that I had set the permissions to be Scripts Only in my
> script (ASP) but it looks like the Application is not being created.
> Can someone tell me why the application is not being created and
> perhaps how I can tweak my script to create (or at least set the
> parameters) of the Application. [code below]
>
> Please help!
>
> Phil
>

 >> Stay informed about: GetObject - Changing Web Site Settings 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> IIS All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]