Solved

ADSI - auto creation of virtual directory using ASP&VBScript

Posted on 2000-03-15
2
524 Views
Last Modified: 2012-06-27
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
Comment
Question by:clodaghm
2 Comments
 

Accepted Solution

by:
cfurlin earned 75 total points
ID: 2620830
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
 
LVL 2

Expert Comment

by:DKostov
ID: 2620835
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now