新创建的IIS应用程序池标识的权限集

7

我需要为创建的IIS应用程序池设置日志文件夹的权限。设置权限的代码如下:

<CreateFolder Directory="SiteLogsFolder">
    <util:PermissionEx User="Everyone" Read="yes" GenericRead="yes"/>
    <util:PermissionEx User="[IisSiteUser]" GenericRead="yes" GenericWrite="yes" GenericExecute="yes" Delete="yes" DeleteChild="yes"/>
</CreateFolder>

<CustomAction Id="SetIis6SiteUser" Property="IisSiteUser" Value="NT AUTHORITY\NetworkService"/>
<CustomAction Id="SetIis7SiteUser" Property="IisSiteUser" Value="IIS AppPool\[SITE_APP_POOL]"/>

<InstallExecuteSequence>
  <Custom Action="SetIis7SiteUser" Before="InstallInitialize">IISMAJORVERSION>="#7"</Custom>
  <Custom Action="SetIis6SiteUser" Before="InstallInitialize">IISMAJORVERSION="#6"</Custom>
</InstallExecuteSequence>

这在Windows Server 2003上的IIS 6上运行良好,但在Windows Server 2008上的IIS 7.5上失败。我收到以下错误:

ExecSecureObjects:  Error 0x80070534: failed to get sid for account: IIS AppPool\MyAppPool

调查细节:

  • 我也尝试了 "IIS APPPOOL" 域 - 结果相同。
  • 还尝试了将 PermissionEx 元素的 Domain 和 User 属性设置而不是合并到 User 属性中。仍然出现相同的错误。
  • 在 PermissionEx 中使用活动目录帐户没有问题。同时,在设置时使用活动目录帐户与 IIS 网站池一起使用也没有问题。
  • 如果我尝试为另一个 AppPool(而不是由我的安装程序创建的),例如 IIS AppPool\DefaultAppPool 设置权限,一切都很顺利。只有在设置由我的安装程序创建的 AppPool 的权限时才会出现问题。
  • 我检查了 ConfigureIIs、SchedSecureObjects 和 ExecSecureObjects 的排序,并尝试强制让 ConfigureIIs 在另外两个之前执行(在这个主题中建议)。不幸的是,这也没有帮助。

同样的问题在这里,正在寻找解决方案。 - Elroy Flynn
2个回答

4

我在构建x86 WIX项目时遇到了这个问题。我通过在ConfigureIIs之前安排SchedSecureObjects和ExecSecureObjects来解决它。

<Custom Action="SchedSecureObjects" After="ConfigureIIs" />
<Custom Action="ExecSecureObjects" After="ConfigureIIs" />

当我开始构建x64项目时,问题再次出现。这一次,在执行ConfigureIIs之前,我必须安排64位操作。

<Custom Action="SchedSecureObjects_x64" After="ConfigureIIs" />
<Custom Action="ExecSecureObjects_64" After="ConfigureIIs" />
<Custom Action="SchedSecureObjects" After="ConfigureIIs" />
<Custom Action="ExecSecureObjects" After="ConfigureIIs" />

2

在测试Server 2012时,我确认账户可用之前可能会有延迟。使用以下脚本,我在大约30次尝试中无法找到3个失败的结果。看起来我们需要在创建应用程序池和查找SID之间添加延迟。在我的测试中,从未超过1秒。

param ($id)
if (!$id) {write-host "specify an id"; return}
c:\windows\system32\inetsrv\appcmd add apppool /name:$id /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
$objUser = New-Object System.Security.Principal.NTAccount("IIS APPPOOL\$id")
$sid=""
while (!$sid)
{
  $sid = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
  if (!$sid) {write-host "$id not found"} else {$sid}
  sleep 1
}

当您编写脚本时,这不是一个坏主意。但是,在用户身份创建和使用之间准确地挂起Windows安装程序并不容易 - 它按照内部定义的顺序执行所有操作。可能可以创建延迟自定义操作,但该解决方案将非常笨拙。 - Sasha

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接