Skip to main content

Windows User Connection

Authenticator availability

Native (SRP) and Certificate (X.509) are the self-authenticating principal types every kS provides. Directory authenticators (the LDAP/Kerberos lineages, including the Windows and NIS samples) are build-dependent and not present in every shipped kS.

Windows User Connection

The following example illustrates how to make a connection to a key service with a Windows user.


Code Samples

See the C environment settings for details on setting the project environment.


< c_connect_win.cpp>
/****************************************************************************************
* c_connect_win.c
*
*
*****************************************************************************************/

#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 */

/* Initialize the TE environment */
TEEnvInit();

/* Open a connection */
h = OpenConnectionWithWindowsUser(TE_SSL_CONNECTION, szServerName, lPort);

if (h == 0)
{
PrintError("Connection error:");
}
else
printf("Connected to %s at %d as Windows user.\n\n", szServerName, lPort);

/* Close a connection */
CloseConnection(h);

printf("Disconnected from server\n\n");

/* Uninitialize the TE environment */
TEEnvClose();

return 0;
}
Output
Connected to localhost at 8888 as Windows user.
Disconnected from server