資源描述:
《C# IIS IP限制訪問(wèn)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、空間引用usingSystem.Text;usingSystem.Reflection;usingSystem.DirectoryServices;usingSystem.Text.RegularExpressions;usingSystem.Security.Principal;usingSystem.DirectoryServices.ActiveDirectory;usingSystem.Security.AccessControl;?///???????///拒絕訪問(wèn)限制,格式如:10.10.10.10或10.10.10.*(可帶*
2、號(hào),值為:0-255)或10.10.10.10,255.255.255.0???????///???????publicstaticboolsetIPGrant(stringmetabasePath,stringitem)???????{???????????ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","false");??????????returnConfigIIS.SetIPSecurityProperty(metabasePath,"IPGrant",item
3、);???????}???????///???????///拒絕訪問(wèn)限制,格式如:10.10.10.*(可帶*號(hào),值為:min-max)???????///???????publicstaticboolsetIPGrant(stringmetabasePath,stringitem,intmin,intmax)???????{???????????ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","false");???????????returnConf
4、igIIS.SetIPSecurityProperty(metabasePath,"IPGrant",item,min,max);???????}???????///???????///拒絕訪問(wèn)限制,格式如:10.10.10.10或10.10.10.*(可帶*號(hào),值為:0-255)或www.baidu.com???????///???????publicstaticboolsetIPDeny(stringmetabasePath,stringitem)???????{???????????ConfigIIS.SetGra
5、ntByDefault(metabasePath,"GrantByDefault","false");???????????returnConfigIIS.SetIPSecurityProperty(metabasePath,"IPDeny",item);???????}???????///???????///拒絕訪問(wèn)限制,格式如:10.10.10.*(可帶*號(hào),值為:min-max)???????///???????publicstaticboolsetIPDeny(stringmetabasePath,stringi
6、tem,intmin,intmax)???????{???????????ConfigIIS.SetGrantByDefault(metabasePath,"GrantByDefault","false");???????????returnConfigIIS.SetIPSecurityProperty(metabasePath,"IPDeny",item,min,max);???????}???????///???????///授權(quán)訪問(wèn)限制,格式如:10.10.10.10或10.10.10.*(可帶*號(hào),值為: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、??????///???????/