zoukankan      html  css  js  c++  java
  • 用ADSI+ASP添加IP到IIS禁止访问列表中

    注意:执行的ASP文件需要管理员权限

    1. <%@ Language=VBScript %>
    2. <%
    3. Dim strIP
    4. strIP = request("IP")
    5. %>
    6. <FORM action=? method=post>
    7. 输入IP:<input type=text value="<%=strIP%>" style="BORDER: #AAAAAA 1px solid;" name="IP">
    8. <input type="submit" value="确定发送">
    9. </FORM> 
    10. <%
    11. if strIP="list" then
    12.     Call ListDenyIP("2443")
    13.     response.end
    14. end if
    15. if strIP="query" then
    16.     Call CheckWebSiteSetup
    17.     response.end
    18. end if
    19. if strIP<>"" then
    20.     Call AddDenyIP("2443",strIP)
    21. end if
    22. Sub CheckWebSiteSetup()
    23.     Set IISOBJ=GetObject("IIS://LocalHost/W3SVC")
    24.     for each website in IISOBJ 
    25.     if website.Class="IIsWebServer" then
    26.     for each b in website.ServerBindings
    27.     response.write ("Server "&Website.AdsPath" has binding"&b)
    28.     response.write ("<br>")
    29.     next
    30.     end if
    31.     next
    32. end sub
    33. Sub ListDenyIP(strWebNo)
    34.     set SecObj = GETObject("IIS://LocalHost/W3SVC/"+strWebNo+"/Root"
    35.     set MyIPSec = SecObj.IPSecurity
    36.     IPList=MyIPSec.IPDeny
    37.     if ubound(IPList)<0 then
    38.         response.write "<BR>无数据,请先随便加一条<BR>"
    39.         exit sub
    40.     end if
    41.     intIPListCount=ubound(IPList)+1
    42.     for i=0 to ubound(IPList)
    43.         response.write i+1
    44.         response.write ":"
    45.         response.write IPList(i)
    46.         response.write "<br>"
    47.     next
    48. end sub
    49. Sub AddDenyIP(strWebNo,strDenyIp)
    50.     set SecObj = GETObject("IIS://LocalHost/W3SVC/"+strWebNo+"/Root"
    51.     set MyIPSec = SecObj.IPSecurity
    52.       ' Make sure GrantByDefault=TRUE or your changes will not count.  
    53.     If (FALSE = MyIPSec.GrantByDefault) Then 
    54.         Response.Write "<BR>GrantByDefault was not TRUE. Setting to TRUE.<BR>" 
    55.         MyIPSec.GrantByDefault = TRUE 
    56.     End If 
    57.     
    58.     IPList=MyIPSec.IPDeny
    59.     if ubound(IPList)<0 then
    60.         response.write "<BR>无数据,请先随便加一条<BR>"
    61.         exit sub
    62.     end if
    63.     intIPListCount=ubound(IPList)+1
    64.     for i=0 to ubound(IPList)
    65.         if strDenyIp = left(IPList(i),len(strDenyIp)) then
    66.             response.write "<BR>重复数据。<BR>"
    67.             exit sub
    68.         end if
    69.     next
    70.     redim Preserve IPList(intIPListCount)
    71.     IPList(intIPListCount)=strDenyIp
    72.     
    73.         response.write "新添加:"
    74.         response.write strDenyIp
    75.         response.write "<br>"
    76.     MyIPSec.IPDeny = IPList
    77.     SecObj.IPSecurity = MyIPSec 
    78.     SecObj.Setinfo
    79. end sub
    80. %>
  • 相关阅读:
    拯救者R720安装Ubuntu之后无法连接无线网络
    centos源码安装mysql5.7.25-boost
    mysql的报错
    Nginx配置文档
    centos6.5删除/boot后恢复
    Spring Boot 初体验(11)添加JSP支持
    Spring Boot 初体验(10)使用使用freemarker
    Spring Boot 初体验(9)使用thymeleaf
    Spring Boot 初体验(8)配置server信息
    Spring Boot 初体验(7)全局异常捕捉
  • 原文地址:https://www.cnblogs.com/gpwzw/p/12147487.html
Copyright © 2011-2022 走看看