Solved

ADSI path to Refer to a subdirectory

Posted on 2004-08-23
7
1,269 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 500 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 run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

12 Experts available now in Live!

Get 1:1 Help Now