Is there a way in asp to create a new default web site within IIS
I am setting a content managament system and want to create a new default web site during on of the processes.
So for example if people create a new site within the admin section and call it Jacinto this will create a new virtual directory called Jacinto.
This would then be accessed at
http://localhost/jacinto
I have tried this code
<%
'''''''''''''''''''''''''''''''''
' ADSI ASP Sample Program
' This is a sample of how to create a virtual directory using ADSI.
'
'''''''''''''''''''''''''''''''''
Option Explicit
On Error Resume Next
'''''''''''''''''''''''
' First, open the path to the Web server you are
' trying to add a virtual directory to.
Dim ServObj
Dim VdirObj
Dim Testpath
Set ServObj = GetObject("IIS://LocalHost/w3svc/1/Root")
if (Err <>0) then
Response.Write "GetObject (""IIS://LocalHost/w3svc/1/Root"") Failed! <br>"
Response.Write "Error! " & Err.Number & "(" & Hex(Err.Number) & "): " & Err.Description & "<br>"
Response.End
end if
'''''''''''''''''''''''
' Second, Create the virtual directory (Vdir) path
Set VdirObj = ServObj.Create("IIsWebVirtualDir", "MyVdir")
VdirObj.SetInfo
if (Err<>0) then
Response.Write "CreateObject (""IIS://LocalHost/w3svc/1/Root/MyVdir"") Failed!<br>"
Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &
"<br>"
Response.End
end if
''''''''''''''''''''''''
' Finally, create a Path variable containing the virtual root path and
' set the permissions to read, script, and directory browsing
VdirObj.AccessRead = True
VdirObj.AccessScript = True
VdirObj.EnableDirBrowsing = True
Testpath = "C:\Temp"
VdirObj.Put "Path", (Testpath)
VdirObj.SetInfo
if (Err<> 0) then
Response.Write "Put (""Path"") Failed!"
Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &
"<br>"
Response.End
end if
Response.Write "VDIR successfully created"
''''''''''''''''''''''''
' The minimum amount necessary to create a virtual directory has now
' been completed. If you need to add more, do it here.
%>
from
http://msdn2.microsoft.com/en-us/library/ms951564.aspx
But i get
GetObject ("IIS://LocalHost/w3svc/1/Root") Failed!
Error! 70(46): Permission denied
I have put this file in a dir and given it all permssions..
please help
This is vital