473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

something wrong with my use of System.DirectoryServices

Hi. I am trying to read information out of the IIS metabase (v5.1). Observe
the following code:

using System;
using System.DirectoryServices;
using System.Reflection;

namespace ADSI1
{
class ConfigIIS
{
[STAThread]
static void Main(string[] args)
{
string serverName = "localhost";
string password = "Y@ms,M0s";
DirectoryEntry site = new DirectoryEntry
("IIS://localhost/W3SVC/1/Root/Stowesoft", "localhost\\administrator",
password, AuthenticationTypes.Secure);
Console.WriteLine ( site.Path );
Console.WriteLine();

foreach ( string propName in site.Properties.PropertyNames)
{
Console.WriteLine(propName);
foreach (object value in site.Properties[propName])
{
Console.WriteLine("\tname = " + propName + ", value = "
+ value);
}
}

Console.WriteLine("Done");

}
}
}

At foreach(string propName in site.Properties.ProerptyNames)

I receive the runtime error

An unhandled exception of type 'System.NotSupportedException' occurred in
system.directoryservices.dll

Additional information: The directory cannot report the number of
properties.

I do not NEED to iterate through the properties so much as check the values
of the properties that I want. My underlying goal is to compare the IIS
setup on a production server to the known desired values. So I want to be
able to read the IIS metabase for virtual root. So for a given virtual root,
what are the application settings, what is the local path, authentication
information...

I don't know how to find out these property names. So I either

- need to learn what is wrong with my code for iterating through the
properties OR
- need to know the name of the properties (from some documentation I could
not find that perhaps one could point me to) available so that I can get the
values directly.

Thanks for your help!

Stephanie
Nov 16 '05 #1
1 4838
Running following on W2K3 (IIS6):
{
DirectoryEntry de = new DirectoryEntry("IIS://scenic/W3SVC/1/root",
"administrator", "pwd",
AuthenticationTypes.Secure);

foreach( string myKey in de.Properties.PropertyNames)
{
Console.WriteLine(myKey + " " + de.Properties[myKey].Value);
}
}

dumps :
AccessFlags 513
AccessSSLFlags 0
AppIsolated 2
AuthFlags 5
FrontPageWeb True
AppFriendlyName Default Application
AppPoolId DefaultAppPool
AppRoot /LM/W3SVC/1/ROOT
KeyType IIsWebVirtualDir
Path d:\inetpub\wwwroot
HttpCustomHeaders System.Object[]
ScriptMaps System.Object[]
DefaultDoc Default.htm,Default.asp,index.htm,iisstart.htm,Def ault.aspx
AppAllowClientDebug False
AppAllowDebugging False
AspAllowOutOfProcComponents True
AspAllowSessionState True
AspAppServiceFlags 0
AspBufferingLimit 4194304
AspBufferingOn True
AspCalcLineNumber True
AspCodepage 0
AspEnableApplicationRestart True
AspEnableAspHtmlFallback False
AspEnableChunkedEncoding True
AspEnableParentPaths False
AspEnableTypelibCache True
AspErrorsToNTLog False
AspExceptionCatchEnable True
AspExecuteInMTA 0
AspKeepSessionIDSecure 0
AspLCID 2048
AspLogErrorRequests True
AspMaxDiskTemplateCacheFiles 2000
AspMaxRequestEntityAllowed 204800
AspProcessorThreadMax 25
AspQueueConnectionTestTime 3
AspQueueTimeout -1
AspRequestQueueMax 3000
AspRunOnEndAnonymously True
AspScriptEngineCacheMax 250
AspScriptErrorSentToBrowser True
AspScriptFileCacheSize 500
AspScriptTimeout 90
AspSessionMax -1
AspSessionTimeout 20
AspTrackThreadingModel False
BITSAllowOverwrites 0
BITSHostIdFallbackTimeout 86400
BITSServerNotificationType 0
BITSSessionTimeout 1209600
CGITimeout 300
ContentIndexed True
DirBrowseFlags 1073741886
PasswordChangeFlags 6
AnonymousUserName IUSR_SCENIC
AnonymousUserPass %Z33<cyw@;8*Rt
AspScriptErrorMessage An error occurred on the server when processing the
URL.
Please contact the system administrator.
AspScriptLanguage VBScript
AuthChangeURL /iisadmpwd/achg.asp
AuthExpiredUnsecureURL /iisadmpwd/aexp3.asp
AuthExpiredURL /iisadmpwd/aexp.asp
AuthNotifyPwdExpUnsecureURL /iisadmpwd/anot3.asp
AuthNotifyPwdExpURL /iisadmpwd/anot.asp
BITSHostId
BITSMaximumUploadSize 18446744073709551615
BITSServerNotificationURL
BITSSessionDirectory BITS-Sessions
HttpExpires D, 0x15180
AdminACL System.__ComObject
AspDiskTemplateCacheDirectory %windir%\system32\inetsrv\ASP Compiled
Templates
HttpErrors System.Object[]

Willy.
"Stephanie Stowe" <No****@IWishICould.com> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
Hi. I am trying to read information out of the IIS metabase (v5.1).
Observe
the following code:

using System;
using System.DirectoryServices;
using System.Reflection;

namespace ADSI1
{
class ConfigIIS
{
[STAThread]
static void Main(string[] args)
{
string serverName = "localhost";
string password = "Y@ms,M0s";
DirectoryEntry site = new DirectoryEntry
("IIS://localhost/W3SVC/1/Root/Stowesoft", "localhost\\administrator",
password, AuthenticationTypes.Secure);
Console.WriteLine ( site.Path );
Console.WriteLine();

foreach ( string propName in site.Properties.PropertyNames)
{
Console.WriteLine(propName);
foreach (object value in site.Properties[propName])
{
Console.WriteLine("\tname = " + propName + ", value = "
+ value);
}
}

Console.WriteLine("Done");

}
}
}

At foreach(string propName in site.Properties.ProerptyNames)

I receive the runtime error

An unhandled exception of type 'System.NotSupportedException' occurred in
system.directoryservices.dll

Additional information: The directory cannot report the number of
properties.

I do not NEED to iterate through the properties so much as check the
values
of the properties that I want. My underlying goal is to compare the IIS
setup on a production server to the known desired values. So I want to be
able to read the IIS metabase for virtual root. So for a given virtual
root,
what are the application settings, what is the local path, authentication
information...

I don't know how to find out these property names. So I either

- need to learn what is wrong with my code for iterating through the
properties OR
- need to know the name of the properties (from some documentation I could
not find that perhaps one could point me to) available so that I can get
the
values directly.

Thanks for your help!

Stephanie

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: hykim | last post by:
Hello, everyone. according to MSDN, there is any constructor of System.DirectoryServices.SearchResultCollection Class. if I implement DirectorySearcher.FindAll() method by myself, then how can I...
1
by: Gaab | last post by:
Hi Folks, After the weekend I wanted to start working on my c#/asp.net project, but when I tried to open it on my machine i got the following error: Compilation Error Description: An error...
0
by: Chris Frohlich | last post by:
All, I've built an Employee Directory with ASP.NET app that queries Active Directory for users and builds links with the results. What I'm seeing is really intermittent failures to bind to the...
2
by: Kelvin | last post by:
Hello I am using web matrix develop a login page through Active Directory but I cannot figure out why it is giving me an error when importing system.directoryServices. Any help will do! thank ...
0
by: RSH | last post by:
I am using System.DirectoryServices to query our AD in order to get information about users. I am having problems understanding how to get at the Username and the Email address (to begin with) ...
6
by: Mark Rae | last post by:
Hi, I'm in the process of updating an ASP.NET v1.1 web app to v2. The app uses ActiveDirectory a great deal, and I'm trying to use the new System.Collections.Generic namespace where possible,...
1
by: sasikumarks | last post by:
Hi, Im using the following code to retrieve the user details from the AD server. But when i execute the code,it throws me the error. Please help me in this...
1
by: aamirghanchi | last post by:
Hi, I recently converted an ASP .net 1.1 project to 2.0 in VS 2005. Even though System.DirectoryServices reference has been added to the project, still for some reasons the Imports...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.