c_connect_ldap.c
/****************************************************************************************
* c_connect_ldap.c
*
* Note: See Tricryption Engine SDK for details on how to set the project environment.
*
*****************************************************************************************/
#include <stdio.h>
#include "teagent_c.h"
void PrintError(const char * msg)
{
char szErr[1024];
uint32_t nLength = 1024;
uint32_t nCode = GetLastTEError(szErr, &nLength);
printf("%s Code = 0x%x, Message = %s\n", msg, nCode, szErr);
}
int main()
{
TE_HANDLE h;
char * szServerName = "localhost"; /* server name */
long lPort = 8888; /* port number */
char * szUserName = "cn=bob,o=emedna"; /* user name */
char * szPassword = "bob"; /* password */
/* Initialize the TE environment */
TEEnvInit();
/* Open a connection */
h = OpenConnectionWithLDAPUser(
TE_SSL_CONNECTION, /* connection type */
szServerName, /* TE server name */
lPort, /* TE server port */
szUserName, /* user name */
szPassword /* password */
);
if (h == 0)
{
PrintError("Connection error:");
}
else
printf("Connected to %s at %d as %s\n\n", szServerName, lPort, szUserName);
/* Close a connection */
CloseConnection(h);
printf("Disconnected from server\n\n");
/* Uninitialize the TE environment */
TEEnvClose();
return 0;
}