Code Maverick
Code Maverick

Reputation: 20415

How can I get the name of the account the application pool runs under inside of my WCF method?

BACKGROUND


I have created a Silverlight / WCF based deployment tool that will be hosted in 2 places: the first will touch the development, testing, and staging servers, and the second will touch the production servers.

Inside the tool, it needs to know where it is so that it can show the appropriate environments and their servers for configuration.

The easiest way to do that is to pull the name of the account the WCF service is running under and based on that return the appropriate DeploymentMode value.


PROBLEM


My problem is that I can't get the name of the account the application pool is running under from within my WCF method. All I seem to pull from HttpContext.Current.User.Identity.Name is my own windows logon.

The application pools for both, the tool and the service, are running under a specific domain account, which is not mine.


QUESTION


How can I get the name of the account the application pool runs under inside of my WCF method?

Upvotes: 0

Views: 745

Answers (1)

Martin Costello
Martin Costello

Reputation: 10882

Use Environment.UserName in conjunction with Environment.UserDomainName to build the AppPool Identity Name.

Upvotes: 3

Related Questions