KSC Open API
13.1
Kaspersky Security Center API description
|
Finds hosts by using string filtering. Finds hosts after filtering by the wstrFilter string and creates the server-side collection of the found hosts. Search is performed in the hierarchy of Administration Servers.
For more information, see Extra search attributes for hosts and administration groups.
See also how to use the KlAkOAPI Python package: def FindHostsByQueryString(server, strQueryString): print("Query string: " + strQueryString) strAccessor = KlAkOAPI.HostGroup.KlAkHostGroup(server).FindHosts(strQueryString, ["KLHST_WKS_HOSTNAME", "KLHST_WKS_DN"], [], {'KLGRP_FIND_FROM_CUR_VS_ONLY': True}, lMaxLifeTime = 60 * 60).OutPar('strAccessor') nStart = 0 nStep = 100 oChunkAccessor = KlAkOAPI.ChunkAccessor.KlAkChunkAccessor (server) nCount = oChunkAccessor.GetItemsCount(strAccessor).RetVal() print("Found hosts for query string:", nCount) oResult = KlAkOAPI.Params.KlAkArray([]) while nStart < nCount: oChunk = oChunkAccessor.GetItemsChunk(strAccessor, nStart, nStep) oHosts = oChunk.OutPar('pChunk')['KLCSP_ITERATOR_ARRAY'] for oObj in oHosts: print("Found host: " + oObj["KLHST_WKS_DN"]); oResult.Add(oObj.GetValue("KLHST_WKS_HOSTNAME")) nStart += nStep return oResult def main(): server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password", verify = False) oHosts = FindHostsByQueryString(server, "(KLHST_WKS_FQDN=\"" + socket.getfqdn() + "")") |