in reply to Setting IIS Specific Permissions

Win32::OLE is your friend!

Check out MSDN: Administering IIS Programatically for more information about the metabase and all the other methods and properties that are accessible using ADSI. Here is some sample code that should get you started (pulled from my collection):
use strict; use Win32::OLE qw(in); my $IISServer = "LocalHost"; my $w3serverID = 3; #Connect to the metabase directly onto the root of the third website my $iis_w3c = Win32::OLE->GetObject("IIS://$IISServer/W3SVC/$w3serverI +D/Root") or die "Can't connect to IIS"; $iis_w3c->{AccessRead} = 1; $iis_w3c->{AccessScript} = 1; $iis_w3c->{AccessWrite} = 0; $iis_w3c->{AccessExecute} = 0; #Save this info to the metabase $iis_w3c->SetInfo();
This will disable write and execute permissions on the website. However, if any subfolders have "explicitly set" (rather than inherited) different settings, then you will need to change those also. You can get a list of paths which have set the permission by using the object->GetDataPaths(property, AttributeFlag) method.

There is also a WMI provider that you can use instead of ADSI.

Error: Keyboard not attached. Press F1 to continue.

Update: If you want to disable execution of .cgi, .pl, .php, .asp, etc, you can also remove the "script mapping" from the website. Either do this manually through the MMC or you can do it programmatically using ADSI (described aboved) to disable it on certain folders. A good website is http://www.iisFAQ.com and go to the "ADSI Scripts" section. - loads of useful scripts (mostly vbscript) that you can convert to Perl w\ Win32::OLE.

Replies are listed 'Best First'.
Re: Re: Setting IIS Specific Permissions
by enoch (Chaplain) on Aug 01, 2001 at 20:48 UTC
         Ahhh, ++ $code or die and thank you. I wish I could just find some good docs on Win32::OLE. The OLE browser is okay and the examples in books like Win32 Perl Scripting and Perl for System Administration are good. But, that module seems to do everything including the kitchen sink. I wish I just had a good book on the nuts n' bolts of OLE.

    Thanks,
    Jeremy