【问题标题】:VBscript - How do I change anonymous authentication settings for a specific site?VBscript - 如何更改特定站点的匿名身份验证设置?
【发布时间】:2011-07-01 07:42:15
【问题描述】:

我正在编写一个 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")

【问题讨论】:

    标签: authentication iis-7 vbscript


    【解决方案1】:

    您上面的代码应该可以工作,您是从提升的命令提示符处运行它吗? 您还可以尝试通过设置 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()  
    

    【讨论】:

    • 如何让它使用应用程序池身份而不是特定用户?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 2012-10-14
    • 1970-01-01
    • 2021-06-09
    • 2010-11-04
    相关资源
    最近更新 更多