Kaspersky Security Center Automation  10.0
Sample. Creating and destroying master/slave relation.

JScript sample code.

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

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

function AddSlave(
				oKlAkSlaveServers, 
				strDisplayName, 
				lGroupId,
				strSlaveAddress,
				strMasterAddress)
{
	//connecting to the slave server candidate
	var oSlaveServer = AcquireAdServerProxy(strSlaveAddress);
	g_oLog.WriteLine("Slave server version is " + oSlaveServer.VersionId);

	//acquire slave server certificate
	var oSlaveCert = oSlaveServer.Certificate;

	//now add "slave server" to master server
	g_oLog.WriteLine("Adding slave server \"" + strDisplayName + "\" into group " + lGroupId); 

	//fill attributes
	var oProps = new ActiveXObject("klakaut.KlAkParams");
	oProps.Add("KLSRVH_SRV_CERTIFICATE", oSlaveCert);
	oProps.Add("KLSRVH_SRV_DN", strDisplayName);
	oProps.Add("KLSRVH_SRV_GROUPID", lGroupId);
	var lId = oKlAkSlaveServers.AddServer(oProps);

	//make slave server know that it is a slave server now

	//acquire master server certificate
	var oMasterCert = oKlAkSlaveServers.AdmServer.Certificate;

	//fill attributes
	var oMasterProps = new ActiveXObject("klakaut.KlAkParams");
	oMasterProps.Add("KLSRV_MASTER_SRV_SSL_CERT", oMasterCert);
	oMasterProps.Add("KLSRV_MASTER_SRV_ADDR", strMasterAddress);

	oKlAkSlaveServers.SetMasterServer(oSlaveServer, oMasterProps);
	return lId;
};

function RemoveSlave(oKlAkSlaveServers,  lSlaveId)
{
	//connect to the slave before removing it
	var oSlaveServer = oKlAkSlaveServers.Connect(lSlaveId, -1);

	// Clear master server address and certificate from the slave server settings 
	oKlAkSlaveServers.SetMasterServer(oSlaveServer, null);

	//Remove slave server object on the master server
	oKlAkSlaveServers.RemoveServer(lSlaveId);
};


var g_oFileSystemObject;
var g_oLog;

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

var oAdmServer = AcquireAdServerProxy("localhost:13000");

oKlAkSlaveServers = new ActiveXObject("klakaut.KlAkSlaveServers");
oKlAkSlaveServers.AdmServer = oAdmServer;

var oGroups = new ActiveXObject("klakaut.KlAkGroups");
oGroups.AdmServer = oAdmServer;

//adding a slave server
var lSlaveId = AddSlave(
		oKlAkSlaveServers, 
		"test slave server",
		oGroups.GroupIdGroups,
		"localhost:13100", //slave address
		"localhost:13000");  //master addres as it is seen from slave

//now remove all it back
RemoveSlave(oKlAkSlaveServers, lSlaveId);

g_oLog.Close();