|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis article is about managing IIS programmatically. It provides a class library that represents the tree hierarchy used by IIS for its every aspect. The project is accompanied by a Windows Forms applications that is used to pinpoint and extract any data required. BackgroundFor the company I work, we have several applications of which two are N-Tier, requiring a Smart Client, an application server, and single or more databases. The deployment of our product to an existing client is difficult, and requires database schema upgrade and website restart. Additionally, creating a new environment needs to be parameterized. So, in order to create a Deploy and Environment Application, an IIS management know-how was required. After searching online, I found some methods, but none that could give an object oriented approach to the problem. Also, there are few knowledge base articles, especially from Microsoft, about this stuff. For example, the version of IIS in a query could not easily be found, and whenever it was mentioned, it required a Registry or file query, which is not helpful when managing IIS remotely. Explaining the libraryThe class library is The understanding of the libray requires very good understanding of The properties are represented with the classes
Here is what every class represents in the hierarchy. Service:It represents the IIS Service. It is the entry point for the IIS management system. The service holds the reference to single or multi
Both Some of the properties of child nodes are propagated to the owner node, because it seemed to me that they should be placed there. For example, Using the codeIn the this.service = new Service("LocalHost");
The IIS hierarchy is represented with a tree, and when selecting on a node on the tree, a dataset with its properties is produced and shown on the right. Because all nodes of the IIS hierarchy have not been created in a typed class, a If a new property is required to be typed, then you create it with the same name and corresponding type. Extra functionality to parse, for example, data from the IIS must be implemented. For example, public int Port
{
get
{
try
{
return Convert.ToInt32(ServerBindings.Replace(":", ""));
}
catch (Exception)
{
}
return -1;
}
set { ServerBindings = String.Concat(":", value.ToString(), ":"); }
}
Points of interestThe state of the public WebSiteStates State
{
get
{
DirectoryEntry site = new DirectoryEntry(base.SourceEntry.Path);
return (WebSiteStates)Convert.ToInt32(site.Properties["ServerState"].Value);
}
}
Whenever a tree node requires to show all of its children in the tree, just add this in the constructor: base.AddChildrenNodes();
The above structure may require more code, but it gives a typed and so much more meaningful representation of what happens in any Directory Service of Microsoft. That includes the Active Directory Service and, as far as I know, Microsoft Exchange. Microsoft is very secretive about the way things are stored in these services, so the Tree and Grid approach provides a helpful insight of the service which can be user to create the appropriate classes, and gradually build or extend a library. HistoryThis is version 1 of the library. It currently provides types functionality for IIS only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||