Skip to content
conradojr edited this page Dec 10, 2013 · 2 revisions

To start using the modSIC service from your .NET application, the first step is to include in your project some DLLs that are provided in the modSIC package. The crucial part that is exposed by these modules is the **ModSicConnection **class, through which all interaction with the modSIC service is made. Internally, the modSIC Connector DLL makes WCF calls to communicate with the modSIC Service endpoint.

The DLLs that have to be added are:

  • Modulo.Collect.OVAL.dll

  • Modulo.Collect.Service.Client.dll

  • Modulo.Collect.Service.Contract.dll

These files can be found in "modSIC Client" under the installation folder.

Connecting to a modSIC service

string serviceAddress, userName, passWord, clientId;
// Initialize variables...
var modSicConn = new ModSicConnection(serviceAddress, userName, passWord, clientId);

serviceAddress is the machine where the modSIC service is running, not the machine that is to be probed. Quite often, this will be "localhost" or "127.0.0.1". userName and passWord are the credentials to the modSIC service. Upon installation, the default is "admin" / "Pa$$w@rd".

clientId is an optional identifier for the machine/user/program that is calling the modSIC service. We suggest building a string from the host name and/or user name and/or running program.

Requesting a collect on a target

First thing, the target machine's credentials must be encapsulated in a Credential object, then the SendCollect method must be called:

Credential targetLoginInfo = new Credential();
targetLoginInfo.UserName = machineUser;
targetLoginInfo.Password = machinePass;
targetLoginInfo.Domain = machineNTDomain;
targetLoginInfo.AdministrativePassword = superuserPass;
var requestResult = modSicConn.SendCollect(targetAddress, targetLoginInfo, ovalDefs, extVars);
if (requestResult.HasErrors)
{
    // Error handling
}
Dictionary<String, String> sendCollectResult = requestResult.Requests.ToDictionary(r => r.ClientRequestId, r => r.ServiceRequestId);
string collectRequestID = sendCollectResult.First().Value;

ovalDefs is the raw XML text of the OVAL definitions to be collected on the target machine. If the definitions require external variables, provide them in extVars. (Again, raw XML text.)

The returned object is of type SendRequestResult. The ID of the collection job may be obtained from it in the manner shown above. Note that, even though a SendRequestResult may potentially contain a number of request IDs, this form of the SendCollect method returns only one, so it's OK to get its first element.

Checking the status of a collect job (or many)

ColectInfo[] collections = modSicConn.GetCollectionsInExecution();

This method returns an array of CollectInfo objects that can be explored to track the progress of the collect job(s) that have been sent by the program. ColectInfo has the following properties:

CollectRequestId - a string holding the collect ID. You should compare this with the ID that was received when a collect was requested.

ReceivedOn- a DateTime indicating when the request was accepted by the modSIC service.

Address - the target machine address or hostname.

ClientId - the client ID that was passed in the ModSicConnection constructor. Can be used to filter all jobs that were started by this client.

Status - a CollectRequestStatus enumeration indicating the collect's progress:

  • Open (received but not yet started)

  • Close (finished, OVAL results are available)

  • Executing (in progress)

  • Canceled (collect was aborted by user)

StartTime - a DateTime indicating when the modSIC Service effectively started probing the target machine.

Retrieving an OVAL results document

string resultXMLData = modSicConn.GetOvalresults(collectID);

This method returns an OVAL results XML in string form. It may be saved as-is in a text file with the .xml suffix.

Cancel an ongoing collection

bool cancelOK = modSicConn.CancelCollect(collectID);

This method aborts a collect job as lon as it's in the Open or Executing state.