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.
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
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.
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.
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".
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