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.

In reply to Re: Setting IIS Specific Permissions by $code or die
in thread Setting IIS Specific Permissions by enoch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.