Solved

ADSI path to Refer to a subdirectory

Posted on 2004-08-23
7
1,294 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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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