accessing IIS virtual directories and other directories programmatically

Skip to first unread message


Feb 21, 2008, 6:10:52 PM2/21/08
Hi all,

I have a need to access the virtual directories and other directories that
fall under an IIS website and change certain properties using c#. I use the
System.DirectoryServices and can get the root virtual directory using the
following string "IIS://testServer/W3SVC/1/Root/". I can then loop through
all virtual directories and application under this web server. What I can't
do is access a subdirectory that has not been designated as either virtual
directory or an application in IIS.

Now to my question, since I know that IIS is actualy part of active
directory is there any other way to get to and change the properties of a
normal directory that is under a virtual directory. I hope I made myself

Thanks in advance to all the gurus out there



Joe Kaplan

Feb 29, 2008, 2:57:00 PM2/29/08
IIS is not part of Active Directory. I think you are confusing the ADSI
provider model with the fact that ADSI is called Active Directory Services
Interface. The name isn't really totally appropriate it. ADSI uses a
provider model to attempt to impose a similar domain model (IADs and its
supporting cast) over the top of different types of stores. The main stores
that are still supported are LDAP (AD, ADAM, etc.), WinNT (the local SAM
account database on any Windows machine) and IIS (over the IIS metabase,
which has had different persistence mechanisms in different versions of
IIS). In all cases, the ADSI provider is attempting to translate the ADSI
domain model to underlying APIs such as LDAP, SAM and ABO (for IIS) and
provide a scriptable way to access those functions that otherwise used to
require C++ code. .NET added an interop layer over ADSI, S.DS, which allows
the same type of access to .NET clients.

So, your IIS settings are stored in the metabase (unless you use IIS 7, in
which case there is a new serialization format based on configuration
files), not in AD. The IIS provider is translating your requests into lower
level calls into ABO that manipulate the metabase.

That said, I think the IISWebDirectory interface is the IIS extension to
ADSI that provides you with what you are looking for. There is a pretty
decent discussion on using ADSI for programmatic administration of IIS in
the IIS SDK docs.

Best of luck!

Joe K.

Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
"Steven" <> wrote in message


Apr 24, 2008, 12:57:00 AM4/24/08
This is related to accessing the "windows Authetication" property of
"Authentication" object of virtual directory,under which webservice is

I have webservice running under virtual directory.I want to programatically
check Whether the "Windows Authentication" under "Authentication" folder of
virtual directory is enabled or not.

I need to check this in c# or

Can u please me code to accessing those object programatically.It would
great if some body give me code to do that..

Deepak Udaya Kumar

Sep 9, 2008, 12:21:01 AM9/9/08
Hi deepak,

I too have the same issue..
Have u found a solution?? if so kindly guide me..
Udaya kumar

Reply all
Reply to author
0 new messages