Solved

ADSI path to Refer to a subdirectory

Posted on 2004-08-23
7
1,273 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Here are the symptoms: You start receiving calls from users that one of your legacy web apps isn't coming up, so you log into your IIS 5 server to check it out.  When you pull up the services, you notice that the WWW Publishing service isn't runn…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

912 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

20 Experts available now in Live!

Get 1:1 Help Now