/*
* Copyright (c) 1995-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1995 Regents of the University of Michigan.
* All rights reserved.
*
* open.c
*/
#ifndef lint
"University of Michigan.\nAll rights reserved.\n";
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h> /* calloc(), free(), atoi() for Solaris */
#include <locale.h>
#include <thread.h>
#ifdef MACOS
#include <stdlib.h>
#include "macos.h"
#endif /* MACOS */
#include "msdos.h"
#include <stdlib.h>
#endif /* DOS */
#ifndef VMS
#endif
#endif
#include "lber.h"
#include "ldap.h"
#include "ldap-private.h"
#include "ldap-int.h"
#ifdef LDAP_DEBUG
int ldap_debug;
#endif
#ifndef INADDR_LOOPBACK
#endif
#ifndef MAXHOSTNAMELEN
#endif
/*
* ldap_open - initialize and connect to an ldap server. A magic cookie to
* be used for future communication is returned on success, NULL on failure.
* "host" may be a space-separated list of hosts or IP addresses
*
* Example:
* LDAP *ld;
* ld = ldap_open( hostname, port );
*/
LDAP *
{
int err;
return (NULL);
}
"ldap_open (after ldap_init)\n"), 0, 0, 0);
#ifdef _REENTRANT
#endif
#ifdef _REENTRANT
#endif
ldap_ld_free(ld, 0);
"ldap_open failed, %s\n"),
ldap_err2string(err), 0, 0);
return (NULL);
}
"ldap_open successful, ld_host is %s\n"),
#ifdef _REENTRANT
#endif
return (ld);
}
/*
* Open the default connection
* ld->ld_defconn MUST be null when calling this function,
* ie the connection was never established
* ld should be LOCKed before calling this function
*/
int
{
int err;
return (LDAP_NO_MEMORY);
}
NULL) {
"Default connection to ldap server %s couldn't be "
return (err);
}
return (LDAP_SUCCESS);
}
int
{
int i = 0;
int free = 0;
for (i = 1; i < MAX_THREAD_ID; ++i) {
if (ldap_thr_table[i] == cur) {
return (i);
} /* end if */
} /* end for */
/*
* not in the table, allocate a new entry
*/
for (i = 1; i < MAX_THREAD_ID; ++i) {
if (ldap_thr_table[i] == 0 ||
thr_kill(ldap_thr_table[i], 0) != 0) {
ldap_thr_table[i] = cur;
return (i);
} /* end if */
} /* end for */
/* if table is full, return the first entry, so that it */
/* doesn't core dump */
return (0);
}
/*
* ldap_init - initialize the LDAP library. A magic cookie to be used for
* future communication is returned on success, NULL on failure.
* "defhost" may be a space-separated list of hosts or IP addresses
*
* Example:
* LDAP *ld;
* ld = ldap_init( default_hostname, default_port );
*/
LDAP *
{
char *locale;
i18n_catopen("sdserver");
"ldap_init\n"), 0, 0, 0);
return (NULL);
}
#ifdef _REENTRANT
ld->ld_lockthread = 0;
#endif
return (NULL);
}
/*
* default to localhost when hostname is not specified
* or if null string is passed as hostname
*/
return (NULL);
}
#if defined(STR_TRANSLATION) && defined(LDAP_DEFAULT_CHARSET)
#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
return (ld);
}
/* ARGSUSED */
int
char **krbinstancep, int async)
{
char *p, *q, *r;
int bindTimeout;
"open_ldap_connection\n"), 0, 0, 0);
hostname[ q - p ] = '\0';
while (*q == ' ') {
++q;
}
} else {
/* avoid copy if possible */
curhost = p;
q = NULL;
}
/* now copy */
}
*r++ = '\0';
} else {
}
break;
}
}
} else {
}
if (rc == -1) {
return (rc);
}
if (krbinstancep != NULL) {
#ifdef KERBEROS
*p = '\0';
}
#else /* KERBEROS */
krbinstancep = NULL;
#endif /* KERBEROS */
}
return (0);
}
/*
* ldap_ssl_open - initialize and connect to an ssl secured ldap
* server. First ldap_open() is called and then ssl is layered on top
* of the socket. A magic cookie to be used for future communication
* is returned on success, NULL on failure. "host" may be a
* space-separated list of hosts or IP addresses. CAfile and CApath
* are used first time through, subsequent calls are ignored and can
* be NULL.
*
* Example:
* LDAP *ld;
* ld = ldap_ssl_open( hostname, port, key );
*/
#ifdef LDAP_SSL
int
{
/*
* Creates a new SSL connection. This holds information
* pertinent to this
* connection.
*/
"SSL_new() failed: %s\n"),
return (-1);
}
/* if keyname is non-null, set ssl keypackage name from it */
199, "SSL_set_userid() failed: %s\n"),
return (-1);
}
}
/* Start the SSL connection */
"SSL_connect() failed: %s\n"),
return (-1);
}
return (0);
}
LDAP *
{
int rval;
if (port == 0)
"ldap_ssl_open (after ldap_open)\n"), 0, 0, 0);
return (NULL);
if (keyname)
if (establish_ssl_connection(ld) != 0) {
return (NULL);
}
return (ld);
}
LDAP *
{
int rval;
if (defport == 0)
"ldap_ssl_open (after ldap_open)\n"), 0, 0, 0);
return (NULL);
return (ld);
}
#endif /* LDAP_SSL */