?
Solved

ADSI Code needed to modify website properties in IIS

Posted on 2003-02-23
17
Medium Priority
?
251 Views
Last Modified: 2010-07-27
Hello,

I am looking for ADSI code written in vbscript (ASP) that would allow me to modify the directory properties for a certain directory in a website in IIS.

Usually, in IIS the Home Directory tab, in the folder properties, the option "The designated directory" is chosen. I want to change that to "a redirection to a URL". I want the code to act based upon the website, the directory, and the URL i want that directory to forward to.

Please make sure that the code is functional and bug free, I am willing to work with you in order to debug and achieve the desired objective of the code.
0
Comment
Question by:brkonthru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 7

Expert Comment

by:lavinder
ID: 8006554
Hi

 here is the code

<%
 dim objdir
 set objdir=getobject("IIS://Localserver/W3SVC/1/Root/yourvirtualfolder")
 objdir.httpredirect="http://www.google.com"
 objdir.setinfo
 set objdir=nothing
%>

cheers!!
0
 

Author Comment

by:brkonthru
ID: 8006967
Hello lavinder,

Thanks for the code, ill give it a shot and get back to you.  But how would I change the site back to its original properties when it used to point to a physical directory on a drive ?


Thanks,
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8007300
objdir.path="whateverpathyouwant"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:brkonthru
ID: 8007515
Hello lavinder,

Thanks for the code, ill give it a shot and get back to you.  But how would I change the site back to its original properties when it used to point to a physical directory on a drive ?


Thanks,
0
 

Author Comment

by:brkonthru
ID: 8007535
im not sure why the double post happend!


The code you gave me seems to only apply to virtual directories, and not physical directories under that site. Is it possible to accomplish that ?

Thanks,
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8007732
Hey friend,

 how you will access the physical directories using http protocol ? I think you should create a virtual directory for them and use them.

cheers!!
0
 

Author Comment

by:brkonthru
ID: 8009079
I think you misunderstood me, I have a site that is set to a certain directory in IIS. Lets assume its "c:\site".  This directory has several other directories underneath it, for example, it has "c:\site\d1", so when i enter site.com/d1 , it will automatically go to that physical directory under that site.

What I need to do, is the piece of code where I would be able to change the direction to "site.com/d1=c:\site\d1" to a URL that is completely different, such as "http://www.google.com".  It can be done using the GUI interface in IIS, there must be a way to do it in ADSI
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8014174
Hi

 As far as i know you can access a directory in IIS only if it exists in the metabase. IIS GUI must be showing the directories underneath your c:/site directory, but those child directories do not exist in the metabase, that is why you are not able to access the directory underneath c:/site. To solve your problem, simply set the "httpredirect" property of c:/site/d1 folder through the statements shown in previous posts. It will work, i have tested it on my machine. Earlier my machine was also not showing the folders underneath a particular site in the metabase, but when i set the "httpredirect" property of the folder underneath the site, it worked and also shown an entry in the metabase.

cheers!!
0
 

Author Comment

by:brkonthru
ID: 8061239
Im not sure I follow you, you say "simply set the "httpredirect" property of c:/site/d1 folder through the statements shown in previous posts" but I have tried what you have given me in the previous post and it didnt work, it gave me an error '80070003'.

That is why I mentioned that i need something that applies to physical directories and not virtual ones.


Thanks,
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8062311
Hi

 80070003 error is path not found, can you paste the physical/virtual directory hierarchy here and the code also.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q238956

cheers!!
0
 

Author Comment

by:brkonthru
ID: 8063327
Here is your code modified:

dim objdir
set objdir=getobject("IIS://devserver/W3SVC/2/root/gpziblog")
objdir.httpredirect="http://www.google.com"
objdir.setinfo
set objdir=nothing


now "gpziblog" does exist as a physical directory under the site, not as a virtual directory.  When I execute the code, i get the path not found error '80070003'
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8063554
Ok, yes it'll give "path not found error" because http is unable to recognise physical folders, therefore you will have to create a virtual directory for it.
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8063584
Probably this link might be helpful to you:
http://www.4guysfromrolla.com/webtech/022300-1.shtml
0
 

Author Comment

by:brkonthru
ID: 8063830
Appreciate your followup,

Since this is doable from the GUI interface, there must be a way to do it through ADSI.  I think in the GUI when the HttpRedirect is set, its first converted to a virtual directory, then the httpredirect is set.

So I think its possible to do this in ADSI also, setup/convert the physical directory to a virtual in the site and then apply the httpredirect, can this be done ADSI ?
0
 

Author Comment

by:brkonthru
ID: 8064034
Appreciate your followup,

Since this is doable from the GUI interface, there must be a way to do it through ADSI.  I think in the GUI when the HttpRedirect is set, its first converted to a virtual directory, then the httpredirect is set.

So I think its possible to do this in ADSI also, setup/convert the physical directory to a virtual in the site and then apply the httpredirect, can this be done ADSI ?
0
 
LVL 7

Accepted Solution

by:
lavinder earned 735 total points
ID: 8069518
Hi

 here is the code to create a virtual directory

Dim oIIS, oDir
Set oIIS = GetObject("IIS://localhost/W3SVC/1/Root")
On Error Resume Next
Set oDir = oIIS.GetObject("IISWebVirtualDir", sName)
' This will return error -2147024893 if it doesn't exist
If Err.Number <> 0 Then Set oDir = oIIS.Create("IISWebVirtualDir", sName)
Err.Clear
oDir.AccessScript = True
oDir.Path = yourpath
oDir.SetInfo
oDir.AppCreate True
oDir.SetInfo
Set oDir = Nothing
Set oIIS = Nothing

cheers!!
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8077415
can you explain giving grade "B" ?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 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