appcmd.exe'set'和'list'命令用于服务身份验证问题

时间:2012-01-06 02:46:22

标签: appcmd

对于非描述性标题感到抱歉;不知道怎么说。所以当我在命令提示符下运行以下代码时

%systemroot%\system32\inetsrv\appcmd.exe list config "Default Web Site/Local\Service" -section:system.webServer/security/authentication/windowsAuthentication /clr:4

我得到一小段xml,其中包括

<WindowsAuthentication enabled="false authPersistNonNTLM="true">

我想为此服务启用Windows身份验证,然后运行

%systemroot%\system32\inetsrv\appcmd.exe set config "Default Web Site/Local/service" -section:system.webServer/security/authentication/windowsAuthentication /enabled:"True" /commit:apphost 

如果我重新运行orignal list命令,它仍然返回windowsAuthentication enabled状态为false。 set命令正常工作并启用/禁用我通过进入IIS管理器检查的windowsAuthentication。我认为集合和列表应该修改或重复相同的值。我需要让列表工作(或其他类似的命令),因为我需要检查我的服务的身份验证状态。所以问题是我错过了什么?为什么set和list看起来是两个不同的值,我如何获得此命令(或类似的命令)来返回我在IIS管理器中看到的服务身份验证的启用状态?

顺便说一句,我正在运行IIS 7。不确定这是否有所作为。对不起,如果我遗漏了任何其他必要的细节。不熟悉IIS。

提前干杯

1 个答案:

答案 0 :(得分:3)

appcmd工具对斜杠敏感。

list选项中,请确保只使用正斜杠,否则返回的信息将来自第一个匹配的默认值,而不是您要求的位置。

%systemroot%\system32\inetsrv\appcmd.exe list config "Default Web Site/Local/Service" -section:system.webServer/security/authentication/windowsAuthentication /clr:4
相关问题