Use of SPApplicationPool in SharePoint 2007

By Jatin Prajapati

Explains the SPApplicationPool Class provided in SharePoint 2007

SPApplicationPool clas represents the application pool of each IIS web site instance. This provides use the facility to program against IIS application pool using managed code like C# or VB.NET. Below is the list of some of its properties of SPApplicationPool.

The CurrentIdentityType property presents the IdentityType enumeration value that specifies the type of identity of application pool under which it is running. LocalService, LocalSystem, NetworkService, and SpecificUser are the possible values of IdentityType.

The DisplayName is the read-only property which is the application pool name in IIS.

The Farm property is the reference to the SPFarm object that represents the farm where this application pool resides.

The Id is the GUID that uniquely identifies this appliction pool.

The Name property contains name of the Application Pool in IIS.

The Password property specifies the password of the windows account under which this application pool is running.

The Username property specifics the username of the windows account under which this application pool is running.

The Status property represents the current status of application pool. This is represented by SPObjectStatus enumeration and Disabled, Offline, Online, Provisioning, Unprovisioning and Upgrading are the possible values.

SPApplicationPool has Delete, Provision, Unprovision, Update and UpdateCredentials methods for related operations.

The following code example shows how to use SPApplicationPool object in managed code.

static class Program
    {
         /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
         static void Main()
        {
            SPWebServiceCollection wsc = new SPWebServiceCollection(SPFarm.Local);
            foreach (SPWebService service in wsc)
            {
                 foreach (SPApplicationPool pool in service.ApplicationPools)
                {
                   Console.WriteLine("Name: " + pool.Name);
                   Console.WriteLine("ID: " + pool.Id.ToString());
                   Console.WriteLine("Current Identity: {0}", pool.CurrentIdentityType);
                   Console.WriteLine("Display name: {0}", pool.DisplayName);
                   Console.WriteLine("Status: {0}", pool.Status);
                   Console.WriteLine();
                }
            }
           Console.Read();
        }
     }

Use of SPApplicationPool in SharePoint 2007  (685 Views)