/*
* Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1995 Regents of the University of Michigan.
* All rights reserved.
*
* request.c - sending of ldap requests; handling of referrals
*/
#ifndef lint
static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
#endif
#include <stdio.h>
#include <string.h>
#ifdef MACOS
#include <stdlib.h>
#include <time.h>
#include "macos.h"
#else /* MACOS */
#include "msdos.h"
#include <time.h>
#include <stdlib.h>
#ifdef PCNFS
#include <tklib.h>
#include <tk_errno.h>
#include <bios.h>
#endif /* PCNFS */
#ifdef NCSA
#include "externs.h"
#endif /* NCSA */
#else /* DOS */
#include <errno.h>
#ifdef _AIX
#endif /* _AIX */
#include "portable.h"
#endif /* DOS */
#endif /* MACOS */
#ifdef VMS
#include "ucx_select.h"
#endif
#include "lber.h"
#include "ldap.h"
#include "ldap-private.h"
#include "ldap-int.h"
#ifdef USE_SYSCONF
#include <unistd.h>
#endif /* USE_SYSCONF */
#ifdef NEEDPROTOS
#else /* NEEDPROTOS */
static LDAPConn *find_connection();
static void use_connection();
static void free_servers();
#endif /* NEEDPROTOS */
#ifdef LDAP_DNS
#ifdef NEEDPROTOS
#else /* NEEDPROTOS */
static LDAPServer *dn2servers();
#endif /* NEEDPROTOS */
#endif /* LDAP_DNS */
{
#ifdef STR_TRANSLATION
} else {
#endif /* STR_TRANSLATION */
}
return( ber );
}
void
{
#ifdef STR_TRANSLATION
}
#endif /* STR_TRANSLATION */
}
int
BerElement *ber )
{
int rv;
#ifdef _REENTRANT
#endif
#ifdef LDAP_DNS
#ifdef _REENTRANT
#endif
return( -1 );
}
#ifdef LDAP_DEBUG
if ( ldap_debug & LDAP_DEBUG_TRACE ) {
"LDAP server %s: dn %s, port %d\n",
}
}
#endif /* LDAP_DEBUG */
} else {
#endif /* LDAP_DNS */
/*
* use of DNS is turned off or this is an X.500 DN...
* use our default connection
*/
#ifdef LDAP_DNS
}
#endif /* LDAP_DNS */
#ifdef _REENTRANT
#endif
NULL, 0 );
return ( rv );
}
int
{
int err;
#ifdef _REENTRANT
#endif
/* Be optimistic : increment parentreq initially.
If it fails we must decrement it */
}
if (ld->ld_defconn == NULL){ /* Not connected yet on the default connection, ie init was called not open */
}
#ifdef _REENTRANT
#endif
return( -1 );
}
}
} else {
NULL ) {
}
free_servers( srvlist );
}
}
}
}
#ifdef _REENTRANT
#endif
return( -1 );
}
NULL ) {
#ifdef _REENTRANT
#endif
return( -1 );
}
/* ++parentreq->lr_outrefcnt; */
} else { /* original request */
}
}
#ifdef notyet
extern int errno;
if ( errno == EWOULDBLOCK ) {
/* need to continue write later */
} else {
#else /* notyet */
#ifdef _REENTRANT
#endif
return( -1 );
#endif /* notyet */
#ifdef notyet
}
#endif /* notyet */
} else {
}
/* sent -- waiting for a response */
}
#ifdef _REENTRANT
#endif
return( msgid );
}
LDAPConn *
{
/*
* make a new LDAP server connection
* XXX open connection synchronously for now
*/
== NULL )) {
}
return( NULL );
}
#ifdef _REENTRANT
#endif
if ( connect ) {
break;
}
}
if ( !use_ldsb ) {
}
#ifdef _REENTRANT
#endif
return( NULL );
}
} else {
}
}
/*
* XXX for now, we always do a synchronous bind. This will have
* to change in the long run...
*/
if ( bind ) {
freepasswd = err = 0;
/* Nothing to do */
Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1280, "new_connection: bind no needed with ldapv3\n"), 0,0,0);
} else {
} else {
freepasswd = 1;
} else {
err = -1;
}
}
if ( err == 0 ) {
LDAP_SUCCESS ) {
err = -1;
}
--lc->lconn_refcnt;
}
if ( freepasswd ) {
}
if ( err != 0 ) {
}
}
}
#ifdef _REENTRANT
#endif
return( lc );
}
static LDAPConn *
/*
* return an existing connection (if any) to the server srv
* if "any" is non-zero, check for any server in the "srv" chain
*/
{
#ifdef _REENTRANT
#endif
#ifdef _REENTRANT
#endif
return( lc );
}
if ( !any ) {
break;
}
}
}
#ifdef _REENTRANT
#endif
return( NULL );
}
static void
{
++lc->lconn_refcnt;
}
void
{
if ( unbind ) {
}
}
}
} else {
}
break;
}
}
}
}
0, 0, 0 );
} else {
lc->lconn_refcnt, 0, 0 );
}
}
#ifdef LDAP_DEBUG
void
{
}
if ( !all ) {
break;
}
}
}
void
{
}
LDAP_REQST_INPROGRESS ) ? "InProgress" :
"Writing" );
}
#ifdef _REENTRANT
#endif
}
" * msgid %d, type %d\n",
l->lm_msgid, l->lm_msgtype );
}
}
}
#ifdef _REENTRANT
#endif
}
#endif /* LDAP_DEBUG */
void
{
int i;
} else {
/* free all referrals (child requests) */
}
}
} else {
}
}
}
}
}
}
}
}
}
static void
{
}
}
}
}
/*
* nsldapi_connection_lost_nolock() resets "ld" to a non-connected, known
* state. It should be called whenever a fatal error occurs on the
* Sockbuf "sb." sb == NULL means we don't know specifically where
* the problem was so we assume all connections are bad.
*/
void
{
/*
* change status of all pending requests that are associated with "sb
* to "connection dead."
* also change the connection status to "dead" and remove it from
* the list of sockets we are interested in.
*/
}
}
}
}
#ifdef LDAP_DNS
static LDAPServer *
{
int i, port;
++domain;
} else {
}
return( NULL );
}
p = host;
} else {
*p++ = '\0';
}
server_dn = ++p;
if ( *server_dn == '\0' ) {
}
}
} else {
}
sizeof( LDAPServer ))) == NULL ) {
free_servers( srvlist );
break; /* exit loop & return */
}
/* add to end of list of servers */
} else {
}
/* copy in info. */
free_servers( srvlist );
break; /* exit loop & return */
}
}
}
ldap_value_free( dxs );
}
return( srvlist );
}
#endif /* LDAP_DNS */