Kaspersky Security Center Automation  10.0
HRESULT IKlAkHosts::FindHosts ( [in] BSTR  strFilter,
[in] IKlAkCollection pFields2Return,
[in] IKlAkCollection pSortFields,
[out, retval] IKlAkChunkAccessor **  ppChunkAccessor 
)

Find host by filter string.

Finds hosts that satisfy conditions from filter string strFilter.

Parameters:
strFilter filter string, see Host search string syntax.
pFields2Return array of host attribute names to return See List of host attributes for attribute names
pSortFields array of containers each of them containing two attributes:
  • "Name" of type String, name of attribute used for sorting
  • "Asc" of type Boolean, ascending if true descending otherwise
Return values:
ppChunkAccessor IKlAkChunkAccessor server-side collection of found hosts


See also How to see contents of the IKlAkParams container.

Sample. Function FindHostsForDnFilter finds hosts by the specified filter string and returns array of host names

	function FindHostsForDnFilter(oHosts, strFilter)
	{
		var oFileds2Return = new ActiveXObject("klakaut.KlAkCollection");
		oFileds2Return.SetSize(2);
		oFileds2Return.SetAt(0, "KLHST_WKS_HOSTNAME");
		oFileds2Return.SetAt(1, "KLHST_WKS_DN");
		var oFileds2Order = new ActiveXObject("klakaut.KlAkCollection");
		var oChunkAccessor = oHosts.FindHosts(
								strFilter,
								oFileds2Return,
								oFileds2Order);
		var lRecords = oChunkAccessor.Count;
		oResult = new ActiveXObject("klakaut.KlAkCollection");
		oResult.SetSize(lRecords);
		var enumObj = new Enumerator(oChunkAccessor);
		i =0;
		for (;!enumObj.atEnd();enumObj.moveNext())
		{
			var oObj = enumObj.item();
			var strName = oObj.Item("KLHST_WKS_HOSTNAME");
			var strDN = oObj.Item("KLHST_WKS_DN");
			oResult.SetAt(i, strName);
			++i;
	};
		return oResult;
};

See also Registering update agents for hosts in group sample.