#include <iostream>
#include "teconnection.h"
#include "teagent.h"
#include "teexception.h"
#include "teauthldapctx.h"
using namespace ERUCES;
using namespace std;
int main()
{
string strServerName = "localhost";
long lPort = 8888;
string strUsername = "cn=bob,o=emedna";
string strPassword = "bob";
try
{
auto_ptr<TEConnection> conn =
TEConnection::createInstance(TEConnection::SecureConnection);
auto_ptr<TELdapAuthenticationContext> ctx =
TELdapAuthenticationContext::getInstance();
ctx->setUser(strUsername);
ctx->setPasswd(strPassword);
conn->open(strServerName, lPort, *ctx.operator->());
cout << "Connected to " << strServerName << " at " << lPort
<< " as " << strUsername << "\n" << endl;
conn->close();
cout << "Disconnected from server." << endl;
}
catch (TEException &e)
{
cout << e.getAllMessages() << endl;
}
catch (...)
{
cout << "Unexpected error" << endl;
}
return 0;
}