Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2006, 07:23 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default creating new virtual directory

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

 
Old October 26th, 2006, 07:48 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The article that you reference on the MSDN is wrote in VBScript, however, it is not an ASP page...its a WSH (Windows Script Host) File which means that it is designed to be executed on the server directly, not through a web page.

Simply put, the ASP process runs under the IUSR_xxx account which has no rights to make the calls you are trying to do (that account has very low permissions). If you change the extension of the above code from .asp to .vbs I am pretty sure it will execute as it should.


-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 09:19 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not entirly sure what you mean...

I will change the extension to .vbs but how do i call it online and what permissions am i supposed to change...

Thanks

 
Old October 26th, 2006, 09:24 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Just because something is written in VBScript doesn't mean its an ASP page, it simply means that it is written in VBScript ;]

In so far as WHAT permissions you need, the IUSR account would need almost super user rights to make the changes you are talking about which is not a good idea since any changes to IUSR are machine wide and you are essentially opening pandoras box for a slew of problems to occur.

If you were to grant that account those privelages, that account could do alot of things on your system like, for example, execute programs and such straight from a web browser! Thats a definate bad thing.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 09:31 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dparsons can we chat on yahoo messanger, i am soo confused and i need to finish this soon for uni

thanks

 
Old October 26th, 2006, 09:32 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

While my yahoo account is signed on, it is signed on at home and I am at the office so that is not possible (at least not for another 6 hours or so)

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 09:43 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok.

I will explain what i have done so far..

I have a site in place that allows people to create folders

This works

<%

set objFSO = server.CreateObject("Scripting.FileSystemObject")

Dim strFolderName, name1

name1=session("SiteName")
strFolderName=server.MapPath("../website/theFiles/" & name1) & "/"
'response.Write(strFolderName)
objFSO.CreateFolder strFolderName
%>

This creates a normal folder for example JonsSite and places it under localhost/content/website/theFiles

I thought they dont want to have to type this link everytime they want to get to thier site

so instead of going to http://localhost/content/website/theFiles/JonsSite

they could go to

http://localhost/JonsSite

I wanted to add this funtionality to this page I had, As i know the site name and link on this page..

Is this any clearer. Maybe there is a better way to do this, Please advise..

 
Old October 26th, 2006, 09:52 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I understand what you want to do, but, creating folders is not the same as interfacing with IIS to set that folder up as a virtual directory. In all reality, you could create a COM component that could work between your application and IIS to facilitate what you are doing, creating COM components gets indepth and are a tad difficult.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 09:55 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

haha... so if i dont get this i may be striggling:)

I cant believe thier is hardly and example code on the web.. everything else there is loads.

do you have any?

 
Old October 26th, 2006, 10:02 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I can not provide you with any of the solutions I have done to achieve this (sorry, bound by a company contract) but here is a link that explains it:

http://www.15seconds.com/issue/990107.htm

Its not step by step and by no way meant to be your silver bullet. You will also need to understand Visual C++ to follow that article.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature




Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Directory MeenaG BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 December 2nd, 2006 01:48 PM
creating new virtual directory red_fiesta Classic ASP Basics 0 October 26th, 2006 04:29 AM
Virtual Directory kristina BOOK: Beginning ASP 3.0 1 April 22nd, 2005 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.