资源描述:
《C# IIS IP限制访问》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、空间引用usingSystem.Text;usingSystem.Reflection;usingSystem.DirectoryServices;usingSystem.Text.RegularExpressions;usingSystem.Security.Principal;usingSystem.DirectoryServices.ActiveDirectory;usingSystem.Security.AccessControl; /// ///拒绝访问限制,格式如:10.10.10.10或10.10.10.*(可带*
2、号,值为:0-255)或10.10.10.10,255.255.255.0 /// publicstaticboolsetIPGrant(stringmetabasePath,stringitem) { ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","false"); returnConfigIIS.SetIPSecurityProperty(metabasePath,"IPGrant",item
3、); } /// ///拒绝访问限制,格式如:10.10.10.*(可带*号,值为:min-max) /// publicstaticboolsetIPGrant(stringmetabasePath,stringitem,intmin,intmax) { ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","false"); returnConf
4、igIIS.SetIPSecurityProperty(metabasePath,"IPGrant",item,min,max); } /// ///拒绝访问限制,格式如:10.10.10.10或10.10.10.*(可带*号,值为:0-255)或www.baidu.com /// publicstaticboolsetIPDeny(stringmetabasePath,stringitem) { ConfigIIS.SetGra
5、ntByDefault(metabasePath,"GrantByDefault","false"); returnConfigIIS.SetIPSecurityProperty(metabasePath,"IPDeny",item); } /// ///拒绝访问限制,格式如:10.10.10.*(可带*号,值为:min-max) /// publicstaticboolsetIPDeny(stringmetabasePath,stringi
6、tem,intmin,intmax) { ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","false"); returnConfigIIS.SetIPSecurityProperty(metabasePath,"IPDeny",item,min,max); } /// ///授权访问限制,格式如:10.10.10.10或10.10.10.*(可带*号,值为:0-255)或10.10.1
7、0.10,255.255.255.0 /// publicstaticboolsetDomainGrant(stringmetabasePath,stringitem) { ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","true"); returnConfigIIS.SetIPSecurityProperty(metabasePath,"DomainGrant",item); }
8、 /// /