Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Folder IIS Permissions with IIS 7.0
Old 09-28-2007, 10:56 AM Folder IIS Permissions with IIS 7.0
Junior Talker

Posts: 3
Name: Sam E
Trades: 0
Hi everyone,
I'm a non-programmer who has been given the task at work of updating a utility to work with IIS 7.0 that configures IIS read/script/execute permissions on applications and folders within those applications.

I have figured out how to 'grab' a Site, an Application, and also a Virtual Directory.

However, I am still at a loss as to how to grab a Folder (ie. from IIS Manager, you have Default Web Site -> your ApplicationX -> folders inside this application...Data, Images, etc)

I am coding this in VB, although I would take help in pretty much any language :)


Once I can get a hold of the object in a variable, I have no problems setting the permissions. This is a sample of grabbing an application object, and changing its IIS permissions:

Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
Set oApp = oWebAdmin.Get("Application.SiteName='Default Web Site',Path='MyApplication'")

Call oApp.GetSection("HandlersSection", oHandlersSection)
oHandlersSection.AccessPolicy = 517 (read, execute, script)



If I could just figure out how to get a folder into a variable, I could run the last two lines of code to set individual permissions for that folder.


Does anyone know how to programmatically get a hold of a folder (not a virtual directory) through the WebAdministration interface?


Thanks for your help,
Sam
Sam.E is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-28-2007, 01:20 PM Re: Folder IIS Permissions with IIS 7.0
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Do you mean a folder on the file system, like what a virtual folder is mapped to (or a folder under that tree)?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 01:47 PM Re: Folder IIS Permissions with IIS 7.0
Junior Talker

Posts: 3
Name: Sam E
Trades: 0
Well, I don't want to mix up terminology, so I will explain it a little better:

In IIS Manager, underneath the Default Web Site node, I have my App, lets call it MyApp.

This app points to c:\MyApp. This directory has folders, so c:\MyApp\Data, c:\MyApp\Plugins, etc.

Back in IIS, the only thing that I created was the application "MyApp", and when I pointed it to c:\MyApp, it automatically filled in all of the folder/file structure inside of it. So when I expand the app MyApp in IISManager, I see a bunch of plain folder icons.

It is those folders that I want to modify the read/execute/script permissions on. Lets say for example I want to set MyApp to be read only, but I need the Plugins folder to also allow Scripts/Execute.


So basically I want to modify a file system folder, but modify the IIS related permissions of it, which I can do easily through the IIS Manager UI (with the Handler Mappings feature). There should not be any Virtual Directory creation in the entire process, as far as I can tell.

Does that help?
Sam.E is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 02:14 PM Re: Folder IIS Permissions with IIS 7.0
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Yeah. Unfortunately it's more complex than setting the NTFS permissions. Read/Execute/Script is something only IIS knows about.

Does 7 still keep all its site data in XML?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 03:11 PM Re: Folder IIS Permissions with IIS 7.0
Junior Talker

Posts: 3
Name: Sam E
Trades: 0
Now all configuration data is stored in web.config files for nodes from the Site level down (ie. site, app, vdir/folder)

Top level settings that affect all IIS are stored in a similar file, ApplicationHost.config


And I actually already figured out how to change read/execute/script permissions, basically using a "HandlersSection" object, which coresponds to the handler section of the web.config files, which has a property "AccessPolicy" which you can set to any combination of Read/Write/Execute/Script/etc.

I have a problem finding perhaps an even simpler answer, I know how to set the IIS permissions for an object once I have the object in a variable...I just can't figure out how to get a Folder level in a variable.


I *believe* there is a difference between a true Virtual Directory, and just a folder that shows up in IIS Manager underneath an IIS Application. At least graphically, they have two different icons.

Programmatically, I can grab a VirtualDirectory easily, there is a class VirtualDirectory (just like there is a class Site and Application and ApplicationPool). My problem is that I can't figure out what the object for a Folder (non-VDir) is, or how to access it.

Using the UI I can set these permissions on just a standard run of the mill folder, and a web.config file shows up inside its contents - just like you can do with a Virtual Directory. I just need to access the folder in code.

Hope that clarifies it? Thanks for the assistance so far as well!
Sam
Sam.E is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 11:13 PM Re: Folder IIS Permissions with IIS 7.0
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
I don't think the folders you're looking for are "stored in" or managed by IIS. A virtual directory points to a node in a file system, and then IIS deals with whatever is there while it's running, in memory. Somebody requests a file, the web server looks for it, and returns a 404 if it's not there.

That said, you might find something interesting in the IIS metabase.xml, stored in or under C:\WINDOWS\system32\inetsrv.

Are you trying to do this in code using .net, are you using ADSI, or...?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to Folder IIS Permissions with IIS 7.0
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60148 seconds with 12 queries