2012-12-14 51 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

相關問題