ADSI+ASP添加IP到IIS禁止访问列表中

来源:asp之家 时间:2011-04-02 10:42:00 

代码如下:


<%@ Language=VBScript %> 
<% 
Dim strIP 
strIP = request("IP") 
%> 
<FORM action=? method=post> 
输入IP:<input type=text value="<%=strIP%>" style="BORDER: #AAAAAA 1px solid;" name="IP"> 
<input type="submit" value="确定发送"> 
</FORM> 
<% 
if strIP="list" then 
Call ListDenyIP("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>无数据,请先随便加一条<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>无数据,请先随便加一条<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>重复数据。<BR>" 
exit sub 
end if 
next 
redim Preserve IPList(intIPListCount) 
IPList(intIPListCount)=strDenyIp 

response.write "新添加:" 
response.write strDenyIp 
response.write "<br>" 
MyIPSec.IPDeny = IPList 
SecObj.IPSecurity = MyIPSec 
SecObj.Setinfo 
end sub 
%>

标签:ADSI,ASP,IP,IIS
0
投稿

猜你喜欢

  • asp如何获知Connection对象更多的信息?

    2009-11-23 20:53:00
  • 成为一个顶级设计师的第一准则

    2008-04-18 10:29:00
  • SQL 注入式攻击的终极防范

    2011-04-03 11:21:00
  • 确定能够释放空间的SQL Server数据库文件的脚本

    2010-07-31 12:36:00
  • asp会员系统如何实现“忘记密码”

    2007-09-19 12:17:00
  • 弹出对话框,点击跳出一个可拖动的层(对话框)

    2009-09-07 12:56:00
  • Mysql的最大连接数怎样用java程序测试

    2009-01-14 12:05:00
  • 在 CSS 中关于字体处理效果的思考

    2008-04-25 22:57:00
  • ASP如何输出字符

    2007-09-22 18:41:00
  • javascript弹出窗口总结

    2009-08-21 12:40:00
  • 几个SQL SERVER应用问题解答

    2008-01-01 19:12:00
  • js字放大效果

    2010-09-07 12:18:00
  • 微软证实最新的关键SQL Server漏洞

    2008-12-23 13:31:00
  • 用MySQL做站点时如何记录未知错误的发生

    2010-09-30 14:11:00
  • eWebEditor不支持IE8/IE7的解决方法

    2010-02-28 10:27:00
  • ASP使用MYSQL数据库全攻略

    2009-11-08 18:27:00
  • Mysql入门系列:MYSQL日志文件维护

    2008-11-24 13:10:00
  • 闲聊html和body标签

    2009-02-21 10:50:00
  • ASP无组件上载,带进度条,多文件上载

    2008-10-29 10:03:00
  • 获得当前数据库对象依赖关系的实用算法

    2009-01-08 13:28:00
  • asp之家 网络编程 m.aspxhome.com