Solved

ADSI path to Refer to a subdirectory

Posted on 2004-08-23
7
1,283 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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