立即注册 登录
教研室 返回首页

涛声依旧的个人空间 http://www.jiaoyanshi.com/space-uid-25164.html [收藏] [分享] [RSS]

日志

C#设置IIS下的站点屏蔽IP

热度 1已有 3139 次阅读 2011-7-27 11:12 |个人分类:编程|系统分类:电子商务课件 | 编程, IIS, 屏蔽IP

代码都在附件中,这里只说明几个重要的地方

  • 使用DirectoryEntry获取IIS对象参数DirectoryEntry("IIS://(服务器IP地址)/w3svc/(站点标识)/ROOT");
  • 站点标识获取方法:
            foreach (DirectoryEntry child in ent.Children)
                {
                    if (child.SchemaClassName == "IIsWebServer")//网站的对应为IIsWebServer,应用程序池和服务扩展对应的名称还没有查到
                    {
                        if (child.Properties["ServerBindings"].Value != null)
                        {
                            tmpStr = child.Properties["ServerBindings"].Value.ToString();//获取二级域名参数
                            if (regex.Match(tmpStr).Success)
                            {
                                Response.Write("ServerBindings:" + child.Name);
                            }
                        }
                        if (child.Properties["ServerComment"].Value != null)
                        {
                            tmpStr = child.Properties["ServerComment"].Value.ToString();//获取站点标识参数
                            if (regex.Match(tmpStr).Success)
                            {
                                ServerComment = child.Name.Trim();
                                //lBoxIP.Items.Add("ServerComment:" + child.Name);
                                //liResponse.Write("ServerComment:" + child.Name);
                            }
                        }
                    }
                }
3.附件中的IISBlockedIpList 类为操作类
         
GetIpList():获取受限IP;
          SetIpList():删除原有的重新添加;
          AddIpList():向后累加

下载需要: 2 积分

附件:  shield_visitIP.zip


路过

鸡蛋

鲜花

握手

雷人
分享到:
   举报 收藏 分享

发表评论 评论 (1 个评论)

回复 reynh 2012-6-18 21:16
正好想用,可惜要积分,下不了

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

全部涛声依旧的最新日志

热门日志导读

回顶部