Authentication VBscript-如何更改特定站点的匿名身份验证设置?

Authentication VBscript-如何更改特定站点的匿名身份验证设置?,authentication,iis-7,vbscript,Authentication,Iis 7,Vbscript,我正在编写一个VBscript,我想更改web服务器上特定站点的任意身份验证配置。但是,我不确定这是如何在提交路径中完成的。目前,我可以在全球范围内更改设置,但我只想针对一个特定的站点文件夹。我最好的猜测是简单地将站点路径包含在MACHINE/WEBROOT/APPHOST的末尾 'CHANGE ANONYMOUS AUTHENTICATION GLOBALLY (working code): Set adminManager = CreateObject("Microsoft.Applica

我正在编写一个VBscript,我想更改web服务器上特定站点的任意身份验证配置。但是,我不确定这是如何在提交路径中完成的。目前,我可以在全球范围内更改设置,但我只想针对一个特定的站点文件夹。我最好的猜测是简单地将站点路径包含在MACHINE/WEBROOT/APPHOST的末尾

'CHANGE ANONYMOUS AUTHENTICATION GLOBALLY (working code):

Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")

Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST")

anonymousAuthenticationSection.Properties.Item("enabled").Value = True
anonymousAuthenticationSection.Properties.Item("userName").Value = "myUser"
anonymousAuthenticationSection.Properties.Item("password").Value = "myPass"

adminManager.CommitChanges()



'MY BEST GUESS AT TARGETING A SPECIFIC SITE (returns error 80070005):

Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Sites/InsideFTL/Corp/redirects/netXposure")

您上面的代码应该可以工作,您是从提升的命令提示符运行它吗? 您还可以尝试通过设置CommitPath来确保它正在提交到ApplicationHost.config,以确保它不是锁定问题,并确保运行脚本的标识具有对它的写访问权限

'CHANGE ANONYMOUS AUTHENTICATION For Default Web Site:
Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site")
anonymousAuthenticationSection.Properties.Item("enabled").Value = True
anonymousAuthenticationSection.Properties.Item("userName").Value = "myUser"
anonymousAuthenticationSection.Properties.Item("password").Value = "myPass"
adminManager.CommitChanges()  

如何使其使用应用程序池标识而不是特定用户?