CopyCode The Code is as follows: <% @ Language = VBScript %>
<%
Dim strip
Strip = request ("ip ")
%>
<Form action =? Method = post>
Input IP address: <input type = text value = "<% = strip %>" style = "border: # aaaaaa 1px solid;" name = "ip">
<Input type = "Submit" value = "confirm to send">
</Form>
<%
If strip = "list" then
Call listdenyips ("2443 ")
Response. End
End if
If strip = "query" then
Call checkwebsitesetup
Response. End
End if
#
If strip <> "" then
Call adddenyip ("2443", strip)
End if
Sub checkwebsitesetup ()
Set iisobj = GetObject ("IIS: // localhost/W3SVC ")
For each website in iisobj
If website. Class = "iiswebserver" then
For each B in website. serverbindings
Response. Write ("server" & website. adspath "has binding" & B)
Response. Write ("<br> ")
Next
End if
Next
End sub
#
Sub listdenyip (strwebno)
Set secobj = GetObject ("IIS: // localhost/w3svc/" + strwebno + "/root ")
Set myipsec = secobj. ipsecurity
Iplist = myipsec. ipdeny
If ubound (iplist) <0 then
Response. Write "<br> no data, please add one <br>"
Exit sub
End if
#
Intiplistcount = ubound (iplist) + 1
#
For I = 0 to ubound (iplist)
Response. Write I + 1
Response. Write ":"
Response. Write iplist (I)
Response. Write "<br>"
Next
End sub
Sub adddenyip (strwebno, strdenyip)
Set secobj = GetObject ("IIS: // localhost/w3svc/" + strwebno + "/root ")
Set myipsec = secobj. ipsecurity
'Make sure grantbydefault = true or your changes will not count.
If (false = myipsec. grantbydefault) then
Response. Write "<br> grantbydefault was not true. setting to true. <br>"
Myipsec. grantbydefault = true
End if
Iplist = myipsec. ipdeny
If ubound (iplist) <0 then
Response. Write "<br> no data, please add one <br>"
Exit sub
End if
#
Intiplistcount = ubound (iplist) + 1
#
For I = 0 to ubound (iplist)
If strdenyip = left (iplist (I), Len (strdenyip) then
Response. Write "<br> duplicate data. <Br>"
Exit sub
End if
Next
Redim preserve iplist (intiplistcount)
Iplist (intiplistcount) = strdenyip
Response. Write "added :"
Response. Write strdenyip
Response. Write "<br>"
Myipsec. ipdeny = iplist
Secobj. ipsecurity = myipsec
Secobj. setinfo
End sub
%>