开发者

Determine the SharePoint Application Pool Account Using Sharepoint API?

开发者 https://www.devze.com 2022-12-21 18:30 出处:网络
Is there a way of determining the user login used for the Application P开发者_StackOverflowool identity using the SharePoint API?

Is there a way of determining the user login used for the Application P开发者_StackOverflowool identity using the SharePoint API?

Thanks, MagicAndi


This article gives a very useful code snippet to get the application pool identity's username:

string sAppPoolUsername = SPContext.Current.Site.WebApplication.ApplicationPool.Username;  

Update Managed to bring this down to a one-liner, given above.


One way to do it - when you run your code with SPSecurity.RunWithElevatedPrivileges, it is actually executed under the application pool's account. All you have to do is look at System.Environment.UserName at that moment.

However, I believe there is a more elegant way to achieve this.

0

精彩评论

暂无评论...
验证码 换一张
取 消