Modify IIS Folder Permission

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to change the permission on what I am calling a "web
folder" in IIS.

I tried the code below, but it's not working?

public static void ModifyDirectory(string parent, string ModifyDir)

{

const int MD_AUTH_BASIC = 0x00000002; //Basic
authentication available.

DirectoryEntry folderRoot = new DirectoryEntry(parent);
folderRoot.RefreshCache();
DirectoryEntry modDir;
modDir =
folderRoot.Children.Find(ModifyDir,"IIsWebFileSetting");

// Set Properties
modDir.CommitChanges();
modDir.Properties["UNCUserName"][0] = "administrator";
modDir.Properties["UNCPassword"][0] = "mae008";
modDir.Properties["DefaultLogonDomain"][0] = "gold-t2";
modDir.Properties["AuthFlags"][0] = MD_AUTH_BASIC;

modDir.CommitChanges();
modDir.Close();
folderRoot.Close();

Thank you,

Mark
 
Mark said:
I am trying to change the permission on what I am calling a "web
folder" in IIS.

I tried the code below, but it's not working?

public static void ModifyDirectory(string parent, string ModifyDir)

{

const int MD_AUTH_BASIC = 0x00000002; //Basic
authentication available.

DirectoryEntry folderRoot = new
DirectoryEntry(parent);
folderRoot.RefreshCache();
DirectoryEntry modDir;
modDir =
folderRoot.Children.Find(ModifyDir,"IIsWebFileSetting");

// Set Properties
modDir.CommitChanges();
modDir.Properties["UNCUserName"][0] =
"administrator";
modDir.Properties["UNCPassword"][0] = "mae008";
modDir.Properties["DefaultLogonDomain"][0] =
"gold-t2";
modDir.Properties["AuthFlags"][0] = MD_AUTH_BASIC;

modDir.CommitChanges();
modDir.Close();
folderRoot.Close();

Thank you,

Mark

These properties are not valid for IIsWebFileSetting, they belong to
IIsWebVirtualDir.
I guess to misunderstood the purpose of these properties, what are you
trying to achieve?

Willy.
 
Sorry about that...my description was weak!

I need to change Directory Security permission on folders under the IIS
default web site tree:

Internet Information Services
- Machine Name
- Web Sites
-Default Web Site
+testfolder

Specifically: on the the Directory Securty Tab (right click on a folder
under the Default Web Site) click the edit button next to Anonymous access
and authentication control, uncheck Anonymous access, check Basic
authenticatoin and enter Domain and password...and finally uncheck Integrated
Windows authentication.

I may have chosen the wrong class "IIsWebFileSetting" to change the
properties described above...which also could have added to the confusion.

I am using windows server 2000, with IIS 5.0

I know in the end we are really just changing/entering data in the IIS
metabase, right?

Thank you so much for taking the time to help....I'm really stuck on this one.

Mark
 
Back
Top