【问题标题】:Delete IIS authorization rules "All users"删除 IIS 授权规则“所有用户”
【发布时间】:2019-02-14 04:31:04
【问题描述】:

我试图从我们的一项网络服务中删除特定的 IIS 授权规则。 我需要使用“允许”模式删除用户“所有用户”。

我试过用这个命令

Clear-Webconfiguration -Filter /system.webServer/security/authorization -Force -PSPath 'IIS:\sites\IAI Application Customizer'

我可以删除所有创建的规则,但只有“所有用户”规则仍然存在。

我希望你能帮助我解决这个问题。 谢谢

【问题讨论】:

    标签: powershell iis authorization


    【解决方案1】:

    这是一个已知问题,我至少可以使用 IIS7 重现该问题:https://social.technet.microsoft.com/Forums/en-US/46cb1905-424e-4bf1-a9e4-514e274b7582/iis-clearwebconfiguration-cmdlet-needs-to-be-executed-twice-for-inherited-url-authorization-rules?forum=winserverpowershell

    您必须调用Clear-WebConfiguration 两次才能删除所有继承的规则。示例:

    Clear-WebConfiguration -Filter "/system.webServer/security/authorization/add[@users='*' and @roles='' and @verbs='']" -PSPath "IIS:\Sites\my_site"
    Clear-WebConfiguration -Filter "/system.webServer/security/authorization/add[@users='*' and @roles='' and @verbs='']" -PSPath "IIS:\Sites\my_site"
    Add-WebConfiguration -Filter "/system.webServer/security/authorization" -Value (@{AccessType="Allow"; Users="my_user"; Permissions="Read, Write"}) -PSPath "IIS:\Sites\my_site"
    

    【讨论】:

      【解决方案2】:

      也许您可以更改该服务的web.config 文件。

      <authorization>
          <remove accessType="Allow" users="*" />
      </authorization>
      

      【讨论】:

      • 我使用 aouthomatic pwoershell 脚本。它在所有服务器上运行。所以没有人可以编辑它。
      【解决方案3】:

      这是我的解决方案。

      $webConfigPath = "C:\Users\SOGL_D\Desktop\test.xml"
      
      $xml = [xml](get-content $webConfigPath)   # Create XML object and open the web.config file
      
      
      foreach( $item in  $xml.configuration."system.webServer".security.authorization.add )  # Traverse through all modules 
      { 
              if( $item.users -eq "*" )                          # Checking if the current module is to be removed 
              { 
                 $xml.configuration."system.webServer".security.authorization.RemoveChild($item);   # Remove the desired module when found 
              } 
      }
      
      $xml.Save($webConfigPath)   # Save the updated web.config file

      【讨论】:

        【解决方案4】:

        这对我有用:

        C:\Windows\System32\inetsrv\appcmd.exe 设置配置 /section:system.webServer/security/authorization /-"[accessType='Allow', users='*']"

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-11-18
          相关资源
          最近更新 更多