#include<string>
#include<iostream>
#include "teagent.h"
#include "teconnection.h"
#include "teexception.h"
#include "teauthuserctx.h"
#include "teauthwinctx.h"
#include "teobject.h"
#include "teadmin.h"
#include "tewinprincipal.h"
using namespace ERUCES;
using namespace std;
int main()
{
string strServer = "localhost";
long nPort = 8888;
string strAdminUser = "admin";
string strAdminPswd = "password1A";
try
{
auto_ptr<TEConnection> conn = TEConnection::createInstance(TEConnection::SecureConnection);
conn->open(strServer, nPort, strAdminUser, strAdminPswd);
cout << "Connected to " << strServer << " as " << strAdminUser << endl << endl;
TEAdmin admin;
admin.attachConnection(conn.operator->());
TEObjectContainer container;
admin.getRoleList(container);
for ( int i=0; i<container.size(); i++ )
{
const TEUserRole* role = static_cast<const TEUserRole*>(container[i]);
cout << endl;
cout << "Role ID: " << role->getRoleId() << endl;
cout << "Role Name: " << role->getRoleName().c_str() << endl;
cout << "Operation Count: " << role->OperationIdCount() << endl;
TEObjectContainer opIDs;
role->getOperationIds(opIDs);
for (int j=0; j<opIDs.size(); j++)
{
const TEUInt32 *id = static_cast<const TEUInt32*>(opIDs[j]);
cout << "\tOperation ID: " << id->getValue() << endl;
}
}
admin.detachConnection();
conn->close();
cout << "Disconnected from " << strServer << endl;
}
catch (TEException &e)
{
cout << e.getAllMessages().c_str() << endl;
}
catch (...)
{
cout << "Unexpected error" << endl;
}
return 0;
}