Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ADSI path to Refer to a subdirectory

Posted on 2004-08-23
7
Medium Priority
?
1,322 Views
Last Modified: 2012-05-05
I'm writing IIS admin scripts using code like this:

        Set objIISVDir = objIIS.Create("IISWebVirtualDir", "Live")
        objIISVDir.Put "Path", "d:\mywebdir"
        objIISVDir.Put "AccessRead", True
        objIISVDir.Put "AccessScript", True
        objIISVDir.Put "DefaultDoc", "logon.asp"
        .....

Thats working OK, now I need to access a physical subdirectory in order to change the content expiry settings

I can do this:

        Set objIISVDir = getobject("IIS://localhost/W3SVC/1/Root/Live")

but I can't do this

        Set objIISVDir = getobject("IIS://localhost/W3SVC/1/Root/Live/userfiles")

So "Live" obviously exists, but userfiles does exist as a subdirectory and yet I can't get an IIS object to point to it.

I don't want to make it a virtual directory, I just want to set the content expiry on the subdir as you can in IIS

Any ideas ?
thanks
0
Comment
Question by:plq
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Author Comment

by:plq
ID: 11869149
I've also tried this

        Set objIISVDir = GetObject("IIS://localhost/W3SVC/1/root/Live")
        Set objItem = objIISVDir.GetObject("IISWebDirectory", "userfiles")

and this

        Set objIISVDir = GetObject("IIS://localhost/W3SVC/1/root/Live")
        Set objItem = objIISVDir.GetObject("IISWebDirectory", "/userfiles")

first one gives "the system cannot find the path specified"

and second one gives automation error. The directory definitely exists and is visible in IIS and windows explorer
0
 
LVL 9

Expert Comment

by:BigC666
ID: 11874794
howdy,

i asum that you have looked at this http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/iis/reskit/iischp8.mspx

has some good examples at the bottom

hope that this helps
0
 
LVL 8

Author Comment

by:plq
ID: 11874849
Thanks, yes I have searched and searched but I couldn't see the answer there or anywhere else. examples for this are thin on the ground and the documentation is v.crap
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 9

Expert Comment

by:BigC666
ID: 11874870
haven't tried what your doing myself, however i did hear something about folder levels being to deep.

sorry maby someone else can help
0
 
LVL 14

Accepted Solution

by:
alimu earned 2000 total points
ID: 11878284
Try getting metaedit from the MS site http://support.microsoft.com/default.aspx?scid=kb;en-us;301386&sd=tech
and have a look at the metabase you're working with.
From what I understand, the directories included in the metabase hierarchy under \root are only the ones that do not inherit settings from their parent directories.  i.e. Virtual directories, directories with different permission configurations, directories setup as applications, etc.
i.e. Live is a virtual directory so it will be in the metabase.  \live\userfiles, however, won't show in the metabase unless you've altered it's configuration from the default.

eg scenario: a site stores all files in inetpub\wwwroot.
your web root = inetpub\wwwroot directory.
There are no virtual directories, alternating permissions or application settings below the root level in IIS.
In this scenario, there will be no nodes in the metabase below \ROOT

hope this makes sense - best if you download metaedit and take a look at your web to make this clearer.
AJ.
0
 
LVL 8

Author Comment

by:plq
ID: 11878501
Thanks alimu,

I put metaedit on the server, and sure enough, the metabase only goes down to "Live", userfiles doesn't show in there.

That got me thinking that I could keep it as an "IISWebDirectory" and still create it, and that worked, see the last bit of code in here :

            Set objIIS = GetObject(sIISPathBase)
           
            '   Create the vdir
           
            Set objIISVDir = objIIS.Create("IISWebVirtualDir", "IIS://localhost/W3SVC/1/Root/Live")
            objIISVDir.put "Path", sWebDir
            objIISVDir.put "AccessRead", True
            objIISVDir.put "AccessScript", True
            'objIISVDir.put "EnableWebServiceExtension", "ASP"
            objIISVDir.put "DefaultDoc", "logon.asp"
            objIISVDir.AppCreate2 APPLICATION_OUT_PROCESS_IIS5          ' High (isolated)
            objIISVDir.put "AppFriendlyName", objDB.DBName
            objIISVDir.put "HTTPEXPIRES", "D,0x00000000"                ' Expire immediately
           
            objIISVDir.AccessExecute = False
            If objDB.WindowsAuthInstall = True Then
                objIISVDir.AuthAnonymous = False
                objIISVDir.AuthBasic = True
                objIISVDir.AuthNTLM = False
            Else
                objIISVDir.AuthAnonymous = True
                objIISVDir.AuthBasic = False
                objIISVDir.AuthNTLM = False
            End If
            objIISVDir.ContentIndexed = False
            objIISVDir.EnableDirBrowsing = False
           
            objIISVDir.SetInfo
           
            '   Unexpire the subdirs
           
            Set objItem = objIISVDir.Create("IISWebDirectory", "userfiles")
            objItem.put "HTTPEXPIRES", ""                            ' no expiration so downloads work
            objItem.SetInfo

I'd seen several other people post this problem on message boards but none were offered a solution. :)
0
 
LVL 14

Expert Comment

by:alimu
ID: 11887785
sounds good, glad you've found a fix - there's not many detailed examples around of using ADSI & IIS.
If you're always going to be changing content expiry on the same folders, you could just set those particular folders up as applications / with different settings so that they do show up in the metabase - although if your code works, it's more flexible the way you have it.
cheers,
AJ.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Today I came across an interesting issue that had me pulling my hair out.  I was troubleshooting a new internal web site which uses integrated security instead of anonymous.  When browsing the site from my laptop, I was able to access it with no iss…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

604 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