使用AppCmd设置特定的IIS 7站点?

Sno*_*owy 10 authentication scripting iis-7 batch-file

我在单个默认网站上有一台带有多个apps/vdirs的IIS 7计算机.我想用这个身份验证设置其中两个:anonymous - off impersonation - on forms auth - off windows auth - on

我想用appcmd.exe做这个,但似乎无法正确地获得语法.有人有运气吗?

谢谢.

Car*_*res 20

您应该尝试配置编辑器(包含在IIS 7.5中,可从http://www.iis.net/download/AdministrationPack下载IIS 7.0 ),它可以自动生成AppCmd.exe命令以及javascript和托管代码.使用它我生成了以下(默认网站):

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"False"  

appcmd.exe set config "Default Web Site" -section:system.web/identity /impersonate:"True"  

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /enabled:"True"  /commit:apphost
Run Code Online (Sandbox Code Playgroud)

请注意,使用commit:apphost的是因为这些部分默认是锁定的,这意味着需要使用位置路径在ApplicationHost.config中设置它们.