Submitting software inventory records to an SMS 2003 MP using the MP API

There are several supported ways to add data to the SMS database but they typically come from an SMS 2003 advanced client.  If you want to add data to an existing client without having to make the agent on the client send it up, or add data to the database for a non-SMS client, then you can use the MP API.

The SMS SDK contains documentation and some sample code for submitting data via the MP API.  There are some other things you’ll need to do in order to get the MP API working with SMS 2003 SP1 and above.

Below is an example of using the MP API to submit software inventory data to a Management Point.  This data gets converted from XML to a SIC by the MP, then moved to the site server, and finally loaded into the database.  Keep in mind that the software inventory data I’m loading into the database in this example is the minimum so much more can be added.  Also, you can create your own GUIDs using CoCreateGUID().

Here are some tips when developing/testing submitting discovery data using the MP API.
–  Enable verbose and debug logging on the SMS 2003 Management Point you’re working with.
–  Have an SMS 2003 advanced client already submitting data to this MP.
–  Turn on report archival on the advanced client so you can see what a properly formatted XML looks like.
–  View the following logs in this order: IIS logs (shows IIS handling the message), ccmisapi.log (SMS ISAPI filter), MP_Sinv.log (converts the XML to a SIC), mpfdm.log (moves the SIC from the MP to site server), and sinvproc.log (loads the SIC into the database).
–  Make sure you’ve installed the hotfix from KB917873 onto your SDK.  This article is not published as of 07/03/2006 but the hotfix is still available by calling Microsoft support.
–  Don’t forget to set the Byte Order Mark in your XML attachment.
–  Make sure you call SetClientID, which is only usable if you’ve included the .h/.c files from KB917873 in your project.

–  If the program fails when running on the MP with http:// in front of the MP Name, try running it without the http:// (this goes through COM instead of IIS).
–  Run the DDRExample program first to create a discovery record in the database prior to using this application

//MPAPI-SinvExample.cpp : Defines the entry point for the console application.
//Rslaten 07/2006

#include “stdafx.h”
#include “MPAPI-SinvExample.h”
#include “SmsMsgAPI.h”
#include “SmsMsgAPI_i.c”
#include “strsafe.h”
#ifdef _DEBUG
#define new DEBUG_NEW

#define MAX_BUFFER_LENGTH 0x1000

CWinApp theApp;

using namespace std;

// Macros to perform error handling and make the code cleaner.
#define _BEGIN \
HRESULT __hrRetVal = S_OK; \
{ \

#define _END \
} \
__End: \

#define _RETVAL __hrRetVal

#define _CHECKHR(expr) if(FAILED(expr)) { __hrRetVal=expr; goto __End; }

int wmain( int argc, wchar_t *argv[], wchar_t *envp[] )
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
// TODO: change error code to suit your needs
_tprintf(_T(“Fatal Error: MFC initialization failed\n”));
nRetCode = 1;
if (argc < 2)
printf(“Usage:MPAPI-HinvExample.exe <

Comments (1)

  1. There are several supported ways to add data to the SMS database but they typically come from an SMS…