I'm using the SPSecurity.RunWithElevatedPrivileges.... allow to "impersonate" the super user "sharepoint\system" account.
Is the "sharepoint\system" account is an alias of the app pool identity of the current web application?
So if my app pool identity is a custom user (with email and other information), how can i retrieve its information? (the information i'm trying to get is the email address...the custom app pool user email has a value, the "sharepoint\system" account email has no value!!!)
I also tried to retrieve the appPool identity by using the WindowsIdentity.Impersonate(IntPtr.Zero) method but...nothing!
So any ideas????
Points to note:
SPSecurity.RunWithElevatedPrivileges
delegate method runs under the SharePoint\System
accountSharePoint\System
account has super user privileges. However it is recognized within the SharePoint run time environment but not by the windows security system, i.e. it doesn't represent the account under which the AppPool is runningIf you want to access the e-mail address of the user account under which the AppPool is running, you may try...
SPSecurity.RunWithElevatedPrivileges(delegate {
using (SPSite siteCollection = new SPSite("Url"))
{
using (SPWeb site = siteCollection.OpenWeb())
{
Console.WriteLine(string.Format("Current Logged in User is {0}. And Email Id: {1} ", site.CurrentUser.LoginName ,site.CurrentUser.Email));
appPoolAccount = siteCollection.WebApplication.ApplicationPool.Username;
SPUser appPoolUser = site.Users[appPoolAccount] as SPUser;
Console.WriteLine(string.Format("AppPool User is {0}. And Email Id: {1} ", appPoolUser.LoginName, appPoolUser.Email));
Console.ReadKey();
}
}
});
Email
property of the SPUser
object as I did above..