CEPM Dotnet Agent Guide V3.3.1.0
Deploying the Cisco Agent in a COM Application

Table Of Contents

Deploying the Cisco Agent in a COM Application

Using the COM Agent in VB

Using the COM Agent in MFC


Deploying the Cisco Agent in a COM Application


While dealing with COM applications (for example, applications developed using VC++, ATL, VB, C++, and C), a COM agent (PEP agent for COM) is used. This COM agent is a wrapper that provides a wide range of configuration properties, which can be used to configure the application in appropriate way from the command line.

To deploy the COM agent in a COM application:


Step 1 Convert the dll file, Com.Cisco.Agent.Pep.dll, into a tlb file, Com.Cisco.Agent.Pep.tlb.


Note In the build process of COM agent, create and register a type library (Com.Cisco.Agent.Pep.tlb) of Com.Cisco.Agent.Pep.dll using the following command lines.

regasm Com.Cisco.Agent.Pep.dll/tlb <folderpath>/Com.Cisco.Agent.Pep.tlb
regasm Com.Cisco.Agent.Pep.dll/codebase/tlb <folderpath>/Com.Cisco.Agent.Pep.tlb

This type library is created using the Assembly Registration tool (Regasm.exe) so as to enable the COM client to use the Assembly seamlessly. This tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. The Assembly Registration tool can generate and register a type library when you apply the /tlb: option. COM clients require that the type libraries to be installed in the Windows registry. Without this option, Regasm.exe only registers the types in an assembly, not the type library. This type library (Com.Cisco.Agent.Pep.tlb) is created in the same folder where the corresponding dll is located.

Step 2 Copy Com.Cisco.Agent.Pep.tlb file into the ...\ApplicationName folder of the application.

Step 3 Copy pep_config.xml and Log.config files into \ApplicationName\Debug folder.


Note You must set the application name and application group name in the pep_config file. Other attributes like username, password, and URL related to the PDP must be mentioned in the pep_config file.


Step 4 To test whether the deployment is successful or not, refer to the following example, which states how to use the COM agent with VB and VC++.


Using the COM Agent in VB

To deploy the COM agent in a VB application:


Step 1 Open VB console.

Step 2 Create a new Standard EXE or open an existing application

Step 3 Choose Project > References.

Step 4 Find your class in the available references list (see Figure 3-1).

Figure 3-1 Reference Class

To define entitlement, select a button (for example) and add the following code:

Private Sub Command1_Click()
    Dim i As Cepm.SoapAuthorizationManager
    Dim result As Boolean
    Set i = Cepm.SoapAuthorizationManager.GetInstance 
    result = com_manager->IsUserAccessAllowed 
("username","ApplicationGroupName:ApplicationName:PageName","any");	
End Sub

This code deploys the COM agent in your application.


Note To test whether the deployment is successful or not, run the VB application. The specified button is rendered only if you are authorized to view it.



Using the COM Agent in MFC

The implementation of COM agent in MFC includes the #import "CepmAgent3.3.tlb" statement in your header file as well as using namespace CepmAgent.

Open your application in which you want to integrate the agent and copy the following code into the pages or controls for which you want to define entitlement:

void CNickDlg::OnOK() 
{
CString strMessage;
CoInitialize(NULL);
CEPM::IAuthorizationManager *com_manager;
CEPM::IAuthorizationManagerPtr 
p1(__uuidof(SoapAuthorizationManager.GetInstance));
com_manager = p1;
VARIANT_BOOL result = 
com_manager->IsUserAccessAllowed("username","ApplicationGroupName:ApplicationName:PageName
","any");
strMessage.Format("Result is: %d", result);
	MessageBox(strMessage, "Result", MB_ICONASTERISK | MB_ICONINFORMATION);
}

This code deploys the COM agent in your MFC application.


Note To test whether the deployment is successful or not, run the MFC application. The specified button is rendered only if you are authorized to view it.