ClearBox Server™ v1.2 Developer's Guide

ICSVAccounting::LogTACPacketCSVEx

When server extension calls this method and passes it an array of TACACS+ attribute-value pairs found in the TACACS+ accounting packet (although this type of packets is not restricted), then server logs these attributes to the accounting logfile, every set of attributes on a new line, separating their values by a delimiter set in SetCSVOptions.

This method differs from LogTACPacketCSV in the way that server extension is responsible for creating and managing the file passed to this method, while LogTACPacketCSVEx uses log files automatically managed by the server.

Server extension should define logfile parameters before calling this method. It is done by making call to ILivingstonAccounting::SetLoggingOptionsEx or ILivingstonAccounting::SetLoggingOptions, inherited by ICSVAccounting interface.

Besides this, SetLoggedAttributesNames should be called to specify what attributes should be logged.

HRESULT LogTACPacketCSVEx(
	[in] unsigned long attributesNum,
	[in] AVPAIR* inpAttributes,
	[in] TAC_AUTHORPARAMS* userInf,
	[in] long fileHandle);

Parameters

attributesNum
[in] Number of elements in the array pointed by inpAttributes. Should not be 0.
inpAttributes
[in] Array of TACACS+ attribute-value pairs that server should log. Generally, these attributes are those passed to server extension's ITACACSAccounting::ProcessAccounting implementation as inpAttributes parameter. Should not be NULL.
userInf
[in] A structure describing user associated with the accounting data passed as inpAttributes parameter. Server extension may pass NULL pointer or a pointer passed to server extension's ITACACSAccounting::ProcessAccounting implementation as accParams parameter. This parameter is needed as long as it contains values for some of pseudo-attributes listed in SetLoggedAttributesNames article except for '@time' attribute. If server extension needs not to log these pseudo-attributes, it may pass NULL as an argument.
fileHandle
[in] Server extension should cast this parameter as HANDLE of the file were accounting data is logged. This must be valid handle of opened file with write access.

Return Values

This method may return E_INVALIDARG if attributesNum=0, inpAttributes=NULL or SetLoggedAttributesNames were not called before.

Thread Safety

This method can be called from any thread.

Memory Management

Server extension should allocate and free memory for inpAttributes and userInf parameters. If server extension uses inpAttributes and userInf parameters passed to ITACACSAccounting::ProcessAccounting implementation, then this memory is managed by the server.

Remarks

Server extension may pass any TACACS+ attribute-value pairs to this method, but only attributes that were specified explicitly in call to SetLoggedAttributesNames are logged. If an attribute was listed in array passed to SetLoggedAttributesNames but it's not present in the inpAttributes array, empty value is logged.

Example Code

This code uses m_pAcc as ICSVAccounting interface pointer stored in ICommonExtenderEx::InitializeEx implementation. It makes server log accounting data into the file created by server extension.

//Implementation of ITACACSAccounting::ProcessAccounting
STDMETHODIMP CTest::ProcessAccounting(
	long tag, TAC_AUTHORPARAMS * accParams,
	unsigned long avSize, AVPAIR * avPairs,
	VARIANT_BOOL start, VARIANT_BOOL update,
	USERADDRESS * userAddr, ACCOUNTINGSTATUS * status)
{
	*status=A_OK;
	if (start==VARIANT_TRUE)
		return S_OK;

	// m_hFileHandle is a handle for a file created 
	// by server extension somewhere
	return m_pAcc->LogTACPacketCSVEx(avSize,avPairs,accParams,
		(long)m_hFileHandle);
}

See Also

ICSVAccounting, Server services, CSV Accounting Logging, SetLoggedAttributesNames, LogTACPacketCSV


© 2001-2003 XPerience Technologies. www.xperiencetech.com

Created by chm2web html help conversion utility.