Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 544
  • Last Modified:

ADSI - auto creation of virtual directory using ASP&VBScript

Hi,
I'm trying to automatically generate virtual directories using ADSI. However, when I try to run the script I've written, I get an error (error '80005004')  at the line
Set vDir = vRoot.Create("IIsWebVirtualDir",sVirDir)

where -sVirDir is the name of the virtual dir. to be created, i.e."Test".
          -vRoot is defined as:
           set vRoot = websvc.GetObject("IIsWebVirtualDir", "ROOT") .

I'm running the script on NT Workstation - can virtual directories only be created on NT Server? If not, can you tell what's wrong with my code?
I'm a little concerned about the permissions needed to actually run this script; for the virtual directory from which this script is run (in Internet Service Manager), they are set as NT Challenge/Response. Should anonymous authentication be enabled too (note, I've tried this too and I still get the same error!)?

Thanks a lot
Clo


********Here's the whole script***************
<html>
<body>
<%

sComputer ="localhost"
sPhyDir = "d:\inetpub"
sVirDir = "Test"

'Get Default Web Site Object
set websvc = GetObject("IIS://" & sComputer & "/W3svc/1")

'Verify by printing out ServerComment
'Response.Write "Comment = " & websvc.ServerComment & "<br>"

'Get root of Default Web Site
set vRoot = websvc.GetObject("IIsWebVirtualDir", "ROOT")

'Get Class Definition of virtual directory
Set ClassDefinition = GetObject(vRoot.Schema)

'Create Virtual Directory
Set vDir = vRoot.Create("IIsWebVirtualDir",sVirDir)

'Only setting two properties
vDir.AccessRead = true
vDir.Path = sPhyDir

'Write information back to Metabase
vDir.SetInfo
%>
</body>
</html>
0
clodaghm
Asked:
clodaghm
1 Solution
 
cfurlinCommented:
Uncheck "Allow Anonymous Access" for the server you are running this code on.

This works if you are receiving the "Permission Denied.GetObject" message, and judging from your code above, that probably whats occurring.

Hope this was helpful.

Christopher Furlin
0
 
DKostovCommented:
Hi,
Your code seems to be ok. You can take a look on one of my previous answers
http://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=10179526 
I dont think that the NT Workstation is a problem. The most probable thing from my point of view are the permissions.
Also, you are sure that "vRoot" is a valid object? You are sure that you have not already created "Test" vDirectory?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now