ADSI Virtual directory creation problems
Hi there -
I have posted this in another IIS group and did not receive much help.
Any help help is appreiciated. After posting this, I did some more
research using REGMON and it looks like some registry keys are missing.
I am thinking I am missing some schema elements which are related to
AD(SI).
Here it goes....
After burning about 8 continuous hours, I am really tired with IIS6 and
ADSI's documentation. OK, enough of wining...
I am trying to make an ASP page use a com component to create virtual
directories on the webserver (Windows 2003 SP1 with IIS6(?)). I am
using this VB6 code in the middle tier:
Public Function CreateWebSite(InputString)
On Error GoTo ErrHandler
Dim strArr
Dim sComputer As String
Dim sPhyDir As String
Dim sVirDir As String
Dim strLogDesc As String
'InputString = "localhost~c:\test1~test3"
10 strArr = Split(InputString, "~")
20 sComputer = strArr(0)
30 sPhyDir = strArr(1)
40 sVirDir = strArr(2)
'Get root of Default Web Site
50 Set vroot = GetObject("IIS://LOCALHOST/W3SVC/1/ROOT")
'Get Class Definition of virtual directory
60 Set vdir = vroot.Create("IIsWebVirtualDir", sVirDir)
'Only setting two properties
70 vdir.AccessRead = True
80 vdir.AccessWrite = True
90 vdir.AccessExecute = True
' vDir.apppackagename = "test2"
100 ' vdir.AppCreate2 1
110 'vdir.Put "AppFriendlyName", "test2"
120 vdir.Path = sPhyDir 'vDir.Path = sPhyDir
'Write information back to Metabase
130 vdir.SetInfo
140 Set vdir = Nothing
150 Set vroot = Nothing
160 CreateWebSite = 1 '"WebSite Created Succesfully"
Exit Function
ErrHandler:
Exit Function 'Actually I have other stuff here.
End Function
This simple method is in a class and I am compiling that class as a
dll. I have used a test winform (VB6) and called this class and walked
through the code and it is working fine on my Winxp. I am logged in as
admin onto my XP. Now the problem: When I try to use this same
function from asp on a test server(Win2k3 SP1), it gave me access
problems. I have fixed those by adding IUSR_XYz to the roles in COM
package. I am running the COM pacakge under a admin level user
identity. I have also changed the IIS Service mode to "Run WWW service
in IIS 5.0 isolatoin mode". At this point my asp code is successfully
calling the com component and the code inside the class method started
to execute. But it is failing at line number 60.
Line 60 is: 60 Set vdir = vroot.Create("IIsWebVirtualDir", sVirDir)
'
Set vDir = vRoot.Create("IIsWebVirtualDir", sVirDir)
The error I am logging into eventlog is: Error Number is: -2147463153;
Error description is: Automation error; Error happened at: 60;
Here is my asp file code:
Dim clsTest
Dim intReturn
on error resume next
'Set clsTest =
Server.CreateObject("WebSiteManager.WebSite")
if err.number > 0 then
response.write ("Error while creating object2")
& "<br>"
response.write "error.number: " & err.number
response.end
else
response.write("No problem here 1") & "<br>"
'set clsTest = nothing
end if
intReturn =
clsTest.CreateWebSite("localhost~c:\test1~test2")
if err.number > 0 then
response.write ("Error while creating website")
& "<br>"
response.write "intReturn = " & cstr(intReturn)
& "<br>"
else
response.write("No problem here 2")
set clsTest = nothing
end if
I am not sure why I am running into this error. So I wanted to test
this same code on another windows2003 server(let's call it
testserver3). I have replicated the same settings on to the
testserver2. This is working fine on testserver2. One main difference
between the two win2k3 servers is, one is using DHCP and it is internal
to my network and the other is at a hosting facility (it is a dedicated
server with a dedicated IP address). I don't know if that has anything
to do with creating a virtual directory.
Any help is appreciated.
Thanks,
VK
date: 14 Apr 2005 11:17:35 -0700
author: VK