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 在其他两个之前执行(在这个线程中推荐)。不幸的是,这也没有帮助。
4

2 回答 2

4

当我将 WIX 项目构建为 x86 时,我遇到了这个问题。我通过在 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" />
于 2016-04-25T15:06:31.920 回答
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
}
于 2013-04-27T06:18:32.497 回答