调用IIS接口自动拉黑IP的代码
编辑时间:2019-11-18 作者:Jacen.He 浏览量:1990 来源:aardio更新日志
调用IIS接口自动拉黑IP的代码:

import dotNet; 
var appDomain = dotNet.clr().createAppDomain();

var serverManager = appDomain.load("Microsoft.Web.Administration").createInstance("ServerManager");
var config = serverManager.GetApplicationHostConfiguration();
var ipSecuritySection = config.GetSection("system.webServer/security/ipSecurity","bbs.aardio.com");
var ipSecurityCollection = ipSecuritySection.GetCollection();

var addElement = ipSecurityCollection.CreateElement("add");
addElement.Item["ipAddress"] = "197.197.197.197";
addElement.Item["subnetMask"] = "255.255.255.255";
addElement.Item["allowed"] = false;
ipSecurityCollection.Add(addElement); 
serverManager.CommitChanges();
来说两句吧