473,385 Members | 1,356 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,385 software developers and data experts.

Get properties of IIS Server

Hi,
I am using DirectoryEntry to access IIS properties. After searching
MSDN, I get "The Internet Information Services (IIS), and WinNT providers do
not currently support Count, so each will throw a NotSupportedException.",
so that I cannot use following codes to enumrate properties.

DirectoryEntry _iisServer = new DirectoryEntry("IIS://localhost/W3SVC");
foreach(DirectoryEntry de in _iisServer.Children) {
if (de.SchemaClassName == "IIsWebServer") {
foreach(string key in de.Properties.PropertyNames) {
foreach(object propertyValue in de.Properties[key]) {
MessageBox.Show(propertyValue.ToString(), key);
}
}
}
}

Thus I probably have to explicitly give the property name to get values:

DirectoryEntry _iisServer = new DirectoryEntry("IIS://localhost/W3SVC");
foreach(DirectoryEntry de in _iisServer.Children) {
if (de.SchemaClassName == "IIsWebServer") {
foreach (string s in de.Properties["ServerComment"] ) {
MessageBox.Show(s, "ServerComment");
}
}
}

After searching, I only found one sample
http://www.panayot.com/articles/iis.htm, there are some available IIS
properties.

My qiestion is where can I find all valid properties for IIS 5.0?

Thanks!
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 16 '05 #1
1 8719
Well, or you consult the docs (msdn
http://www.microsoft.com/resources/d...mb_aambref.asp)

or you retrieve the property names from the schema, following is a complete
sample.

using System;
using System.DirectoryServices;
using System.Collections;
using System.Reflection;
namespace Willys
{
class IIsProperties
{
string bindUser = "celeb//administrator";
string bindPwd= "Kevin111";
public void RetrieveSchema()
{
DirectoryEntry entry = new DirectoryEntry ("IIS://scenic/Schema",
bindUser, bindPwd, AuthenticationTypes.ServerBind);
ArrayList classes = new ArrayList(64);
ArrayList props = new ArrayList(256);
foreach (DirectoryEntry child in entry.Children)
{
if (String.Compare(child.SchemaClassName, "class",true) == 0)
{
classes.Add(child.Path.ToString());
}
}
foreach (string class1 in classes)
{
Console.WriteLine(class1);
RetrieveProperties(class1);
}
}
void RetrieveProperties(string path)
{
DirectoryEntry objClass = new DirectoryEntry (path, bindUser, bindPwd,
AuthenticationTypes.ServerBind);
object ads = objClass.NativeObject;
Type type = ads.GetType();
// IIS metadata has no mandatory properties
/*
object o = type.InvokeMember("MandatoryProperties",
BindingFlags.GetProperty, null, ads, null);
Console.WriteLine("******MANDATORY PROPERTIES********");
foreach(object s in (ICollection)o)
Console.WriteLine(s);
*/
Console.WriteLine("******OPTIONAL PROPERTIES********");
object o = type.InvokeMember("OptionalProperties",
BindingFlags.GetProperty, null, ads, null);
foreach(object s in (ICollection)o)
Console.WriteLine("\t" + s);
Console.WriteLine("*************************");
}

}
class Tester
{
static void Main()
{
IIsProperties iisProp = new IIsProperties();
iisProp.RetrieveSchema();
}
}
}

Willy.

"Hardy Wang" <ha********@marketrend.com> wrote in message
news:u%***************@TK2MSFTNGP09.phx.gbl...
Hi,
I am using DirectoryEntry to access IIS properties. After searching
MSDN, I get "The Internet Information Services (IIS), and WinNT providers
do
not currently support Count, so each will throw a NotSupportedException.",
so that I cannot use following codes to enumrate properties.

DirectoryEntry _iisServer = new DirectoryEntry("IIS://localhost/W3SVC");
foreach(DirectoryEntry de in _iisServer.Children) {
if (de.SchemaClassName == "IIsWebServer") {
foreach(string key in de.Properties.PropertyNames) {
foreach(object propertyValue in de.Properties[key]) {
MessageBox.Show(propertyValue.ToString(), key);
}
}
}
}

Thus I probably have to explicitly give the property name to get values:

DirectoryEntry _iisServer = new DirectoryEntry("IIS://localhost/W3SVC");
foreach(DirectoryEntry de in _iisServer.Children) {
if (de.SchemaClassName == "IIsWebServer") {
foreach (string s in de.Properties["ServerComment"] ) {
MessageBox.Show(s, "ServerComment");
}
}
}

After searching, I only found one sample
http://www.panayot.com/articles/iis.htm, there are some available IIS
properties.

My qiestion is where can I find all valid properties for IIS 5.0?

Thanks!
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 16 '05 #2

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

Similar topics

2
by: Gijs Beukenoot | last post by:
Hi all, I have an existing application that checks a few things before it launches another application. One thing that the application needs to check is the subscription properties of both the...
0
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t...
4
by: Lyn | last post by:
Hi, This question may seem a bit academic... To learn more about Access VBA, I have been enumerating the properties of various form controls. This was mostly successful and I have learned a lot...
2
by: Marty McDonald | last post by:
When setting certain datagrid properties with the IDE (as in the property window), they don't seem to take effect. For instance, Font Name. So I have to set these via code-behind at the cell...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
4
by: TS | last post by:
When i try to access the page class or parent properties inside a server control that is nested in another server control, they are null. I don't even call CreateChildControls for the parent...
12
by: Perre Van Wilrijk | last post by:
Hi there, When I started using VB6, I used to write classes with properties and functions as following ... Private lngf1 As Long Private strf2 As String Public Property Get f1() As Long...
8
by: Crazy Cat | last post by:
Hi, When I click on the properties of a linked server, all the General properties are read - only, which means that if I want to edit any general properties I have to delete the linked server...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
1
by: tshad | last post by:
In VB 2008, I have a user control added to the page in the PageLoad event - but the properties are causing me an error. The program (TakeSurveyTest.aspx) using the control (ContactInfo): <%@...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.