6

Is there a way to programmatically determine which application pool a service application is using?

Further i would like to get the information about the service account the app pool is using.

4 Answers 4

6

In powershell use:

Get-SPServiceApplication | FT DisplayName, ApplicationPool

If you want to get the property in your own program you need to get a hold of the Service Application and the cast it to SPIisWebServiceApplication which has the ApplicationPool property

2
  • Casting the SPServiceApplication to SPIisWebServiceApplication in order to get the Application Pool was just what I needed! Though I'd like to be able to get the user name running the app pool, but it looks like the ManagedAccount property is private. Any ideas?
    – athom
    Oct 3, 2012 at 14:50
  • TheColonel please check out my answer as this is providing the username used in the app pool and what name you can look at in the iis manager. The anwser from Per Jakobsen is only showing the information visible in SharePoint, but not inside of IIS on the boxes. Mar 28, 2013 at 12:28
3

You can use in PowerShell the following command:

Get-SPServiceApplication | ForEach-Object { $_.ApplicationPool}

This results in the name of the service application and the account of the application pool.

3

You can use the SharePoint Management Shell to get the information:

Get-SPServiceApplication | Select Name, @{Name="SPAppPoolName"; Expression={$_.ApplicationPool.Name}},  @{Name="IISAppPoolName"; Expression={$_.ApplicationPool.Id}}, @{Name="ProcessAccountName"; Expression={$_.ApplicationPool.ProcessAccountName}}

This command uses expressions to extract the desired parts from the app pool.

  • Name = The name of the service application
  • SPAppPoolName = SharePoint is using a dedicated name you can use inside of the CA but that is not visible in the IIS management view
  • IISAppPoolName = This is the ID of the SP app pool and is used as the name of the app pool if you check in the IIS manager on the servers the service app is running on ProcessAccount = This is the service account the app pool is running under

You can check (should not edit) the configuration of the app pool in the applicationHost.config (C:\Windows\System32\inetsrv\config\applicationHost.config). Search for the id or navigate to the xml element "applicationPools".

0

You could use System.Security.Principal.WindowsIdentity.GetCurrent().Name to identify the Identity in which the current application is running. This Link provides a nice utility which displays the identity under which the aspx is run.

Or read this Question :)

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.