【问题标题】:Sharepoint - Impersonating App Pool IdentitySharepoint - 模拟应用程序池身份
【发布时间】:2014-10-16 18:20:22
【问题描述】:

我正在使用 SPSecurity.RunWithElevatedPrivileges.... 允许“模拟”超级用户“sharepoint\system”帐户。

“sharepoint\system”账号是不是当前web应用的app pool标识的别名?

如果我的应用程序池身份是自定义用户(包含电子邮件和其他信息),我如何检索其信息? (我试图获取的信息是电子邮件地址...自定义应用程序池用户电子邮件有值,“sharepoint\system”帐户电子邮件没有价值!!!)

我还尝试使用 WindowsIdentity.Impersonate(IntPtr.Zero) 方法检索 appPool 身份,但是……没有!

所以有什么想法吗???

【问题讨论】:

    标签: sharepoint impersonation applicationpoolidentity


    【解决方案1】:

    注意事项:

    • SPSecurity.RunWithElevatedPrivileges委托方法中运行的代码在SharePoint\System账户下运行
    • SharePoint\System 帐户拥有超级用户权限。但是它在 SharePoint 运行时环境中被识别,但不被 Windows 安全系统识别,即它不代表 AppPool 正在运行的帐户
    • 当尝试访问服务器文件系统/数据库等 SP 环境之外的资源时,只有 AppPool 身份出现
    • 如果您想访问运行 AppPool 的用户帐户的电子邮件地址,您可以尝试...

      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();
                  }
              }
          });
      
    • 输出看起来像...
    • 因此,如果您真的想获取 AppPool 帐户的 EmailId,请明确选择用户并访问 SPUser 对象的 Email 属性,就像我在上面所做的那样。

    【讨论】:

      猜你喜欢
      • 2011-06-30
      • 2011-08-15
      • 2023-03-17
      • 1970-01-01
      • 2016-07-21
      • 2020-11-16
      • 2013-03-20
      • 2020-09-28
      • 2011-05-07
      相关资源
      最近更新 更多