Get a Remote Engines Configuration Information
The following code sample illustrates how to get a client's configuration information.
Code Sample
See the C++ environment settings for details on setting the project environment.
<cpp_adminlocal_getconfiguration.cpp>
/*****************************************************************************************
*
* cpp_adminlocal_getconfiguration.cpp
*
*
******************************************************************************************/
#include<string>
#include<iostream>
#include "teagent.h"
#include "teconnection.h"
#include "teexception.h"
#include "teauthuserctx.h"
#include "teauthwinctx.h"
#include "teobject.h"
#include "teadmin_local.h"
using namespace ERUCES;
using namespace std;
int main()
{
string strServer = "localhost"; // this is the remote engine, not the TE server.
long nPort = 5050; // this is the local admin port.
string strUser = "ls"; // this is a normal TE user, not necessarily a TE admin user.
string strPswd = "password";
try
{
// Connect to local server
auto_ptr<TEConnection> conn = TEConnection::createInstance(TEConnection::SecureConnection);
auto_ptr<TEUserAuthenticationContext> ctx = TEUserAuthenticationContext::getInstance();
ctx->setUser(strUser);
ctx->setPasswd(strPswd);
ctx->setMode(2); // set to 2 if going to call getConfiguration().
conn->open(strServer, nPort, *ctx.operator->());
cout << "Connected to " << strServer << " as " << strUser
<< " at port " << nPort << endl;
// Local administrator
TEAdminLocal adminlocal;
adminlocal.attachConnection(conn.operator->());
string strXPath = "ErrorLog";
string strXML;
// Get confuguration, client must be online.
adminlocal.getConfiguration(strXPath, strXML);
cout << "XPath = " << strXPath << endl;
cout << "XML = " << strXML << endl;
adminlocal.detachConnection();
// Disconnect from local server
conn->close();
cout << "Disconnected from " << strServer << endl;
}
catch (TEException &e)
{
cout << e.getAllMessages().c_str() << endl;
}
catch (...)
{
cout << "Unexpected error" << endl;
}
return 0;
}
Output
Connected to localhost as ls at port 5050
XPath = ErrorLog
XML =
Disconnected from localhost