Cassie
Cassie

Reputation: 474

Preventing IIS6 from overwriting file permissions

My current work project is to create an auto-updating list of running websites for internal use, to be accessed via a web browser. I figured out that I could do this by writing an ASP script, reading the XML data in MetaBase.xml, and displaying it to the user.

I've gotten my script written and working on my end. The only thing is, I have to customize the file permissions (by default, the restrictions on who can read files in the system directory are strict). I figured out the permissions I need to implement, got it to work...

... But every time someone makes a change to the IIS, the permissions are reset to the default ones.

I've tried everything to prevent this behavior - removed the ability to change user permissions for each account on this file (except a dummy one I set up just in case), changed the ownership to said dummy account and removed permission for all other users to take ownership, etc. Still, every time a change is made to IIS, the ownership changes back to the Administrators group and the permissions are changed back to the default.

Is there any way I can prevent this from occurring? Or, alternatively: if my approach to this problem is completely stupid, can someone suggest a better one?

Thank you!

Upvotes: 0

Views: 175

Answers (1)

CJ Harmath
CJ Harmath

Reputation: 1090

if you are ok with ASP.NET / C# then you can use DirectorEntry to enumerate the list of the sites

See a similar post here: How can I look up IIS site id in C#?

DirectoryEntry de = new DirectoryEntry("IIS://localhost/W3SVC");
foreach (DirectoryEntry child in de.Children)
{
    if (child.SchemaClassName == "IIsWebServer")
    {
        Response.Write(child.Properties["ServerComment"].Value + "<br/>");
    }
}

Permission wise, you might need to run that app under a privileged account

Upvotes: 1

Related Questions