每个AppPool要指定一个身份(identity)来运行。IIS6中AppPool默认运行身份为NT AUTHORITYNETWORK SERVICE。这是一个系统内建帐户,完全受系统控制。它支持所有必要的以服务登录(Log on as a service)的权限,密码也是内部来维护——换句话说,我们可以把以服务登录理解为它可以控制了哪些帐户能够使用、操作远程资源。我们可以通过很多方法控制远程资源的访问。比如修改远程资源ACL表,并允许远端机器访问本地资源;或者在远程访问时换作远端授信帐户(impersonating)进行操作;或者索性让我们的程序运行在某一个配置帐户下——log on as a service。不同的是它是宿主在IIS的AppPool中的,必然收到IIS控制,用户本身没有办法像普通服务程序那样启动它。我要试验的就是指定AppPool以配置帐户启动。
Event Type: Error Event Source: W3SVC Event Category: None Event ID: 1059 Date: 1/18/2008 Time: 11:48:27 AM User: N/A Computer: HITOMI Description: A failure was encountered while launching the process serving application pool "HITOMIWS". The application pool has been disabled.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. 错误二:已经告诉我们所指定的appPool帐户非法。另外一个极重要的提示回答了error一的疑惑:是World Wide Web Publishing Service无法启动w3wp.exe。(这里也回答了文章最初的问题)至此,唯一的问题就是为什么帐户非法?往下看。。。
Event Type: Warning Event Source: W3SVC Event Category: None Event ID: 1057 Date: 1/18/2008 Time: 11:48:27 AM User: N/A Computer: HITOMI Description: The identity of application pool "HITOMIWS" is invalid, so the World Wide Web Publishing Service can not create a worker process to serve the application pool. Therefore, the application pool has been disabled.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
错误三:谜底揭晓了。该账户没有被赋予logontype4,导致它非法。如果有经验的话,这种帐户-logonType控制是在local Security SettingsLocal PolicyUser Rights Assignments里定义的。具体来说就是log on as a service。
Event Type: Failure Audit Event Source: Security Event Category: Logon/Logoff Event ID: 534 Date: 1/18/2008 Time: 11:48:08 AM User: NT AUTHORITYSYSTEM Computer: HITOMI Description: Logon Failure: Reason: The user has not been granted the requested logon type at this machine User Name: HITOMIWEBSERVICE Domain: REDMOND Logon Type: 4 Logon Process: Advapi Authentication Package: Negotiate Workstation Name: HITOMI Caller User Name: HITOMI$ Caller Domain: REDMOND Caller Logon ID: (0x0,0x3E7) Caller Process ID: 640 Transited Services: - Source Network Address: - Source Port: -
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. Start > Run, secpol.msc回车, 打开local Secuirty Settings,展开Local PolicyUser Rights Assignments,选择Log on as a service这个policy,果然里面有NetworkService和sql server的n多帐户,我们再把appPool帐户加到这个list里面。做完之后,machine需要重新启动。等一切再次ready以后,我们再试一下web程序,欣喜看到w3wp.exe已经以指定帐号启动了! 回头再考虑一下我们什么时候要用指定帐户运行web程序呢?It depends。当我们的web 程序要经常访问域内其他节点资源的时候,为提高访问安全要用到指定帐户,加强ACL控制。其实在大多数情况下NetworkService已经可以够用了。