#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";
long nPort = 5050;
string strUser = "ls";
string strPswd = "password";
try
{
auto_ptr<TEConnection> conn = TEConnection::createInstance(TEConnection::SecureConnection);
auto_ptr<TEUserAuthenticationContext> ctx = TEUserAuthenticationContext::getInstance();
ctx->setUser(strUser);
ctx->setPasswd(strPswd);
ctx->setMode(2);
conn->open(strServer, nPort, *ctx.operator->());
cout << "Connected to " << strServer << " as " << strUser
<< " at port " << nPort << endl;
TEAdminLocal adminlocal;
adminlocal.attachConnection(conn.operator->());
string strXPath = "ErrorLog";
string strXML;
adminlocal.getConfiguration(strXPath, strXML);
cout << "XPath = " << strXPath << endl;
cout << "XML = " << strXML << endl;
adminlocal.detachConnection();
conn->close();
cout << "Disconnected from " << strServer << endl;
}
catch (TEException &e)
{
cout << e.getAllMessages().c_str() << endl;
}
catch (...)
{
cout << "Unexpected error" << endl;
}
return 0;
}