2012-12-14 59 views
4

我需要为创建的IIS应用程序池的日志文件夹设置权限。该代码设置权限:为新创建的IIS AppPool身份设置的权限

<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 2008上的Windows Server 2003上正常工作对IIS 6,但失败了IIS 7.5我得到的错误:

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

调查的详细信息:

  • 我也试过“IIS APPPOOL”域 - 相同的结果。
  • 还尝试设置PermissionEx元素的域和用户属性,而不是将它们合并到用户属性中。同样的错误。
  • 在PermissionEx中使用活动目录帐户可以正常工作。当设置时,活动目录帐户也可以与IIS站点池一起正常工作。
  • 如果我尝试设置另一个AppPool的权限(而不是由我的安装程序创建一个,例如IIS AppPool \ DefaultAppPool),再次正常工作。只有当我为我的安装程序创建的AppPool设置权限时才会出现问题。
  • 我检查了ConfigureIIs,SchedSecureObjects和ExecSecureObjects的排序,并尝试强制ConfigureIIs在另外两个之前执行(建议in this thread)。不幸的是,这并没有帮助。
+0

同样的问题在这里寻找解决方案。 –

回答

1

在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 
} 
+0

编写脚本时不是一个坏主意。但是,要在创建用户身份和使用它之间正确暂停Windows安装程序并不那么容易 - 它以内部定义的顺序执行所有操作。它可能会创建一个延迟自定义操作,但该解决方案将非常尴尬 –

1

我在将WIX项目构建为x86时遇到了此问题。我通过在ConfigureIIs之前调度Sc​​hedSecureObjects和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" /> 
+0

谢谢。它有助于 – Vasiliy

相关问题