Kaspersky Security Center Automation  10.0
Sample. Creating ip subnets based on AD Site and Services.

JScript sample code.

var g_strDefaultNamingContext;
var g_oFileSystemObject;
var g_oLog;

function GetDefaultNamingContext()
{
	var oRootDSE = GetObject("LDAP://RootDSE"); 
	var strDefaultNamingContext = oRootDSE.Get("defaultNamingContext");
	g_oLog.WriteLine("DefaultNamingContext is " + strDefaultNamingContext);
	return strDefaultNamingContext;
};

function AcquireAdServerProxy()
{
	var oSrvConnectionProps = new ActiveXObject("klakaut.KlAkParams");
	oSrvConnectionProps.Add("Address", "localhost:13000");
	oSrvConnectionProps.Add("UseSSL", true);

	var oAdmServer = new ActiveXObject("klakaut.KlAkProxy");
	oAdmServer.Connect(oSrvConnectionProps);
	g_oLog.WriteLine("Server version is " + oAdmServer.VersionId);
	return oAdmServer;
};

function DeleteAllSubnets(oIpSubnets)
{
	var oFields = new ActiveXObject("klakaut.KlAkCollection");
	oFields.SetSize(1);
	oFields.SetAt(0, "KLDPNS_ID");
	var oResult = oIpSubnets.EnumDiapasons(oFields);

	enumObj = new Enumerator(oResult);
	for (;!enumObj.atEnd();enumObj.moveNext()) 
	{
		oObj = enumObj.item();
		g_oLog.WriteLine(oObj.Type);
		var nID = oObj.Item("KLDPNS_ID");
		g_oLog.WriteLine("ID to delete is " + nID);
		oIpSubnets.RemoveDiapason(nID);
}; 
};



// Start execution

// prepare logging
g_oFileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
g_oLog = g_oFileSystemObject.CreateTextFile("log.txt", true);

try {
	g_strDefaultNamingContext = GetDefaultNamingContext();

	var oIpSubnets = new ActiveXObject("klakaut.KlAkIpSubnets");
	oIpSubnets.AdmServer = AcquireAdServerProxy();

	var oIpConversions = new ActiveXObject("klakaut.KlAkIpConversions");

	// delete all existing subnets if needed
	// DeleteAllSubnets(oIpSubnets);

	var oRoot = GetObject("LDAP://cn=Subnets,cn=Sites,cn=Configuration," + g_strDefaultNamingContext);
	g_oLog.WriteLine(oRoot.distinguishedName);
	enumObj = new Enumerator(oRoot); 

	var strPartOfName = "MyTestSubnet";

	for (;!enumObj.atEnd();enumObj.moveNext()) 
	{
		oObj = enumObj.item();
		g_oLog.WriteLine(oObj.Name);

		var oIntervals = new ActiveXObject("klakaut.KlAkCollection");
		oIntervals.SetSize(1);
		oIntervals.SetAt(0, oIpConversions.ConvertSubnet(oObj.cn));

		var oPars = new ActiveXObject("klakaut.KlAkParams");
		oPars.Add("KLDPNS_DN", strPartOfName + " - " + oObj.cn);
		oPars.Add("KLDPNS_ILS", oIntervals);
		oPars.Add("KLDPNS_LF", 3600*8);
		oPars.Add("KLDPNS_ScanEnabled", false); //disable network scan for  subnet

		try { 
			var idDiapason = oIpSubnets.AddDiapason(oPars);
			g_oLog.WriteLine("Added diapason " + oObj.cn + ", id is " + idDiapason);
	}
		catch(e)
		{
			g_oLog.WriteLine("Failed to add diapason " + oObj.cn + ": " + e.number + " occured !!! " + e.description);
	};
};
}
catch(e)
{
	g_oLog.WriteLine("Error " + e.number + " occured !!! " + e.description);
};


g_oLog.Close();