IIS中應用程序池的運行賬戶(標識)有以下4個選項
- LocalService 本地服務
- LocalSystem 本地系統
- NetWorkService 網絡服務
- ApplicationPoolIdentify
默認情況下新建的應用程序池標識為ApplicationPoolIdentify,官網文檔解釋(傳送門)為:
If you are running IIS 7.5 on Windows Server 2008 R2, or a later version of IIS, you don't have to do anything to use the new identity. For every application pool you create, the Identity property of the new application pool is set to ApplicationPoolIdentity by default. The IIS Admin Process (WAS) will create a virtual account with the name of the new application pool and run the application pool's worker processes under this account by default.
大概的意思:在IIS7.5以后的版本中,新建的所有程序池默認運行標識為ApplicationPoolIdentity。啟動該應用程序池時,會自動創建一個與應用程序池同名的虛擬賬戶來運行該進程。
說它是虛擬的,是因為在用戶管理里看不到該用戶或用戶組,在命令行下輸入net user也無法顯示,但該帳號又是確實存在的。可以通過任務管理器觀察到w3wp.exe這個web程序進程是以應用程序的名稱作為用戶名運行的。
通過前面的觀察,確定CQApi這個賬戶是隱藏不可見的,那么如果當我們需要操作一個當前項目外的文件夾時,我們需要給這個文件賦予當前運行賬號以操作權限,但是我們直接使用CQApi為關鍵字去查找會發現根本沒有這個賬號。
關鍵:手動輸入IIS AppPool\CQApi (即IIS AppPool\應用程序池名)
除此之外,還可以通過給目錄分配Authenticated Users用戶組來獲取權限
Authenticated Users:Windows系統中所有使用用戶名、密碼登錄並通過身份驗證的賬戶,不包括來賓賬戶Guest,即使來賓帳戶有密碼。 與Everyone的區別在於Everyone包括所有賬戶,如內置的來賓賬戶和LOCAL_SERVICE。
用Authenticated Users代替everyone組可以防止匿名訪問。