Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The classes in the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx" rel="nofollow noreferrer">System.DirectoryServices namespace</a> will help you get that information.</p> <p>Check <a href="http://www.west-wind.com/weblog/posts/10181.aspx" rel="nofollow noreferrer">this article by Rick Strahl</a> for an example:</p> <pre class="lang-cs prettyprint-override"><code>/// &lt;summary&gt; /// Returns a list of all the Application Pools configured /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; public ApplicationPool[] GetApplicationPools() { if (ServerType != WebServerTypes.IIS6 &amp;&amp; ServerType != WebServerTypes.IIS7) return null; DirectoryEntry root = this.GetDirectoryEntry("IIS://" + this.DomainName + "/W3SVC/AppPools"); if (root == null) return null; List&lt;ApplicationPool&gt; Pools = new List&lt;ApplicationPool&gt;(); foreach (DirectoryEntry Entry in root.Children) { PropertyCollection Properties = Entry.Properties; ApplicationPool Pool = new ApplicationPool(); Pool.Name = Entry.Name; Pools.Add(Pool); } return Pools.ToArray(); } /// &lt;summary&gt; /// Create a new Application Pool and return an instance of the entry /// &lt;/summary&gt; /// &lt;param name="AppPoolName"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public DirectoryEntry CreateApplicationPool(string AppPoolName) { if (this.ServerType != WebServerTypes.IIS6 &amp;&amp; this.ServerType != WebServerTypes.IIS7) return null; DirectoryEntry root = this.GetDirectoryEntry("IIS://" + this.DomainName + "/W3SVC/AppPools"); if (root == null) return null; DirectoryEntry AppPool = root.Invoke("Create", "IIsApplicationPool", AppPoolName) as DirectoryEntry; AppPool.CommitChanges(); return AppPool; } /// &lt;summary&gt; /// Returns an instance of an Application Pool /// &lt;/summary&gt; /// &lt;param name="AppPoolName"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public DirectoryEntry GetApplicationPool(string AppPoolName) { DirectoryEntry root = this.GetDirectoryEntry("IIS://" + this.DomainName + "/W3SVC/AppPools/" + AppPoolName); return root; } /// &lt;summary&gt; /// Retrieves an Adsi Node by its path. Abstracted for error handling /// &lt;/summary&gt; /// &lt;param name="Path"&gt;the ADSI path to retrieve: IIS://localhost/w3svc/root&lt;/param&gt; /// &lt;returns&gt;node or null&lt;/returns&gt; private DirectoryEntry GetDirectoryEntry(string Path) { DirectoryEntry root = null; try { root = new DirectoryEntry(Path); } catch { this.SetError("Couldn't access node"); return null; } if (root == null) { this.SetError("Couldn't access node"); return null; } return root; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload