#define LDAP_NO_ATTRS "1.1"
#define LDAP_ALL_USER_ATTRIBUTES "*"
-#define LDAP_COMPAT20
-#define LDAP_COMPAT30
-#if defined(LDAP_COMPAT20) || defined(LDAP_COMPAT30)
-#define LDAP_COMPAT
-#endif
-
-/* LDAP_OPTions defined by draft-ldapext-ldap-c-api-02 */
+/*
+ * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02
+ * 0x0000 - 0x0fff reserved for api options
+ * 0x1000 - 0x3fff reserved for api extended options
+ * 0x4000 - 0x7fff reserved for private and experimental options
+ */
#define LDAP_OPT_API_INFO 0x0000
#define LDAP_OPT_DESC 0x0001
#define LDAP_OPT_DEREF 0x0002
#define LDAP_OPT_ERROR_NUMBER 0x0031
#define LDAP_OPT_ERROR_STRING 0x0032
-/* not defined by current draft */
-/* for LDAPv2 compatibility */
-#define LDAP_OPT_DNS 0x1001 /* use DN & DNS */
+/* 0x33 - 0x0fff not defined by current draft */
+
+/* extended options - none */
+
+/* private and experimental options */
+#define LDAP_OPT_DNS 0x4001 /* use DN & DNS */
/* OpenLDAP specific options */
-#define LDAP_OPT_DEBUG_LEVEL 0x4001 /* OpenLDAP - debug level */
+#define LDAP_OPT_DEBUG_LEVEL 0x5001 /* debug level */
+#define LDAP_OPT_TIMEOUT 0x5002 /* default timeout */
+#define LDAP_OPT_REFHOPLIMIT 0x5003 /* ref hop limit */
/* on/off values */
#define LDAP_OPT_ON ((void *) 1)
int ldapai_vendor_version; /* supplier-specific version * 100 */
} LDAPAPIInfo;
-#define LDAP_FEATURE_INFO_VERSION 1 /* version of api feature structure */
+#define LDAP_FEATURE_INFO_VERSION (1) /* version of api feature structure */
typedef struct ldap_apifeature_info {
int ldapaif_info_version; /* version of this struct (1) */
char* ldapaif_name; /* matches LDAP_API_FEATURE_... less the prefix */
char ldctl_iscritical;
} LDAPControl, *PLDAPControl;
-#define LDAP_MAX_ATTR_LEN 100
+/* LDAP "Standard" Controls */
+#define LDAP_CONTROL_REFERRALS "1.2.840.113666.1.4.616"
+#define LDAP_CHASE_SUBORDINATE_REFERRALS 0x0020
+#define LDAP_CHASE_EXTERNAL_REFERRALS 0x0040
+
+/* LDAP "Extension" Controls */
+
+/* LDAP "Private/Experiemental" Controls */
+
/*
* specific LDAP instantiations of BER types we know about
#define LDAP_IS_LEAF 0x23 /* not LDAPv3 */
#define LDAP_ALIAS_DEREF_PROBLEM 0x24
-#define LDAP_NAME_ERROR(n) (((n) & 0x00f0) == 0x0020)
+#define LDAP_NAME_ERROR(n) (((int)(n) & 0x00f0) == 0x0020)
#define LDAP_INAPPROPRIATE_AUTH 0x30
#define LDAP_INVALID_CREDENTIALS 0x31
#define LDAP_CLIENT_LOOP 0x60 /* new */
#define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* new */
-/* default limit on nesting of referrals */
-#define LDAP_DEFAULT_REFHOPLIMIT 5
-
/*
* This structure represents both ldap messages and ldap responses.
* These are really the same, except in the case of search responses,
} LDAPURLDesc;
#define LDAP_URL_ERR_NOTLDAP 0x01 /* URL doesn't begin with "ldap://" */
-#define LDAP_URL_ERR_NODN 0x02 /* URL has no DN (required) */
+#define LDAP_URL_ERR_NODN 0x02 /* URL has no DN (required) */
#define LDAP_URL_ERR_BADSCOPE 0x03 /* URL scope string is invalid */
-#define LDAP_URL_ERR_MEM 0x04 /* can't allocate memory space */
+#define LDAP_URL_ERR_MEM 0x04 /* can't allocate memory space */
-/* avoid pulling in headers */
+/*
+ * The API draft spec says we should declare (or cause to be declared)
+ * 'struct timeval'. We don't. See LDAPext discussions.
+ */
struct timeval;
/*
* in error.c:
*/
LDAP_F( int )
-ldap_result2error LDAP_P(( LDAP *ld, LDAPMessage *r, int freeit ));
+ldap_result2error LDAP_P(( /* deprecated */
+ LDAP *ld,
+ LDAPMessage *r,
+ int freeit ));
+
LDAP_F( char *)
-ldap_err2string LDAP_P(( int err ));
+ldap_err2string LDAP_P((
+ int err ));
+
LDAP_F( void )
-ldap_perror LDAP_P((
+ldap_perror LDAP_P(( /* deprecated */
LDAP *ld,
LDAP_CONST char *s ));
BerElement *ber;
int i, err, sendabandon;
Sockbuf *sb;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPRequest *lr;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
/*
* An abandon request looks like this:
sendabandon = 1;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
/* find the request that we are abandoning */
for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
if ( lr->lr_msgid == msgid ) { /* this message */
sendabandon = 0;
}
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( ldap_msgdelete( ld, msgid ) == 0 ) {
ld->ld_errno = LDAP_SUCCESS;
} else {
/* send the message */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if ( lr != NULL ) {
sb = lr->lr_conn->lconn_sb;
- } else
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- {
+ } else {
sb = &ld->ld_sb;
}
}
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if ( lr != NULL ) {
if ( sendabandon ) {
ldap_free_connection( ld, lr->lr_conn, 0, 1 );
ldap_free_request( ld, lr );
}
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-
if ( ld->ld_abandoned == NULL ) {
if ( (ld->ld_abandoned = (int *) malloc( 2 * sizeof(int) ))
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
void
ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp,
char **passwdp, int *authmethodp, int freeit ))
{
ld->ld_rebindproc = rebindproc;
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
}
if ( ld->ld_cldapaddrs == NULL
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|| ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
) {
ldap_ld_free( ld, 0 );
DO_RETURN( NULL );
char *
ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
{
- long len;
+ char *attr;
+
+ assert( ld != NULL );
+ assert( entry != NULL );
+ assert( ber != NULL );
Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
* positioned right before the next attribute type/value sequence.
*/
- len = LDAP_MAX_ATTR_LEN;
- if ( ber_scanf( *ber, "{x{{sx}", ld->ld_attrbuffer, &len )
+ if ( ber_scanf( *ber, "{x{{ax}", &attr )
== LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
ber_free( *ber, 0 );
return( NULL );
}
- return( ld->ld_attrbuffer );
+ return( attr );
}
/* ARGSUSED */
char *
ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
{
- long len;
+ char *attr;
+
+ assert( ld != NULL );
+ assert( entry != NULL );
+ assert( ber != NULL );
Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
/* skip sequence, snarf attribute type, skip values */
- len = LDAP_MAX_ATTR_LEN;
- if ( ber_scanf( ber, "{sx}", ld->ld_attrbuffer, &len )
+ if ( ber_scanf( ber, "{ax}", &attr )
== LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
- /* ber_free( ber, 0 ); *//* don't free the BerElement */
return( NULL );
}
- return( ld->ld_attrbuffer );
+ return( attr );
}
ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
{
BerElement ber;
- char attr[LDAP_MAX_ATTR_LEN];
+ char *attr;
int found = 0;
- long len;
char **vals;
Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
ber = *entry->lm_ber;
/* skip sequence, dn, sequence of, and snag the first attr */
- len = sizeof(attr);
- if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
/* break out on success, return out on error */
while ( ! found ) {
- len = sizeof(attr);
- if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+ free(attr);
+ attr = NULL;
+
+ if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
if ( strcasecmp( target, attr ) == 0 )
break;
+
}
+ free(attr);
+ attr = NULL;
+
/*
* if we get this far, we've found the attribute and are sitting
* just before the set of values.
ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
{
BerElement ber;
- char attr[LDAP_MAX_ATTR_LEN];
+ char *attr;
int found = 0;
- long len;
struct berval **vals;
Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
ber = *entry->lm_ber;
/* skip sequence, dn, sequence of, and snag the first attr */
- len = sizeof(attr);
- if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
/* break out on success, return out on error */
while ( ! found ) {
- len = sizeof(attr);
- if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+ free( attr );
+ attr = NULL;
+
+ if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
break;
}
+ free( attr );
+ attr = NULL;
+
/*
* if we get this far, we've found the attribute and are sitting
* just before the set of values.
LDAP_BOOL_ZERO(&gopts);
-#if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) || \
- LDAP_VERSION_MAX > LDAP_VERSION2
LDAP_BOOL_SET(&gopts, LDAP_BOOL_REFERRALS);
-#endif
openldap_ldap_initialized = 1;
return( NULL );
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
krbinstance = ld->ld_defconn->lconn_krbinstance;
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- krbinstance = ld->ld_host;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( (err = krb_mk_req( &ktxt, service, krbinstance, realm, 0 ))
!= KSUCCESS ) {
#define LDAP_URL_URLCOLON_LEN 4
#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL)
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
#define LDAP_REF_STR "Referral:\n"
#define LDAP_REF_STR_LEN 10
#define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
#define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
+
+#define LDAP_DEFAULT_REFHOPLIMIT 5
+
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
#define LDAP_DX_REF_STR "dx://"
#define LDAP_DX_REF_STR_LEN 5
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#define LDAP_BOOL_REFERRALS 0
#define LDAP_BOOL_RESTART 1
LDAP_BOOLEANS ldo_booleans; /* boolean options */
};
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
/*
* structure for tracking LDAP server host, ports, DNs, etc.
*/
struct ldapreq *lr_prev; /* previous request */
struct ldapreq *lr_next; /* next request */
} LDAPRequest;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
/*
* structure for client cache
int ld_msgid;
/* do not mess with these */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPRequest *ld_requests; /* list of outstanding requests */
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- LDAPMessage *ld_requests; /* list of outstanding requests */
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
LDAPMessage *ld_responses; /* list of outstanding responses */
+
int *ld_abandoned; /* array of abandoned requests */
- char ld_attrbuffer[LDAP_MAX_ATTR_LEN];
+
LDAPCache *ld_cache; /* non-null if cache is initialized */
/* stuff used by connectionless searches. */
char *ld_cldapdn; /* DN used in connectionless search */
int ld_cldapnaddr; /* number of addresses */
void **ld_cldapaddrs;/* addresses to send request to */
-#ifndef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
- /* BerElement that this connection is receiving. */
- BerElement ld_ber;
-#endif
+
/* do not mess with the rest though */
BERTranslateProc ld_lber_encode_translate_proc;
BERTranslateProc ld_lber_decode_translate_proc;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPConn *ld_defconn; /* default connection */
LDAPConn *ld_conns; /* list of server connections */
void *ld_selectinfo; /* platform specifics for select */
int (*ld_rebindproc)( struct ldap *ld, char **dnp,
char **passwdp, int *authmethodp, int freeit );
/* routine to get info needed for re-bind */
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
};
/*
char *ldap_host_connected_to( Sockbuf *sb );
#endif /* HAVE_KERBEROS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
int do_ldap_select( LDAP *ld, struct timeval *timeout );
void *ldap_new_select_info( void );
void ldap_free_select_info( void *sip );
void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
int ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
int ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
/*
BerElement *ldap_alloc_ber_with_options( LDAP *ld );
void ldap_set_ber_options( LDAP *ld, BerElement *ber );
-#if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) \
- || defined( LDAP_API_FEATURE_X_OPENLDAP_V2_DNS )
int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid,
LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
int bind );
void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
void ldap_dump_requests_and_responses( LDAP *ld );
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS || LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
/*
* in result.c:
ldap_open( LDAP_CONST char *host, int port )
{
LDAP *ld;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPServer *srv;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
return( NULL );
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
strdup( ld->ld_defhost )) == NULL )) {
}
++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- if ( open_ldap_connection( ld, &ld->ld_sb, ld->ld_defhost,
- ld->ld_defport, &ld->ld_host, 0 ) < 0 ) {
- ldap_ld_free( ld, 0, NULL, NULL );
- return( NULL );
- }
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-
Debug( LDAP_DEBUG_TRACE, "ldap_open successful, ld_host is %s\n",
( ld->ld_host == NULL ) ? "(null)" : ld->ld_host, 0, 0 );
openldap_ldap_global_options.ldo_defbase);
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
free( (char*) ld->ld_options.ldo_defhost );
if ( ld->ld_options.ldo_defbase == NULL ) {
WSACleanup( );
return( NULL );
}
-#endif
if(defport != 0) {
ld->ld_defport = defport;
struct sockaddr_in sin;
struct hostent *hp = NULL;
#ifdef notyet
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
ioctl_t status; /* for ioctl call */
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#endif /* notyet */
/* buffers for ldap_pvt_gethostbyname_a */
DO_RETURN( -1 );
}
#ifdef notyet
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
status = 1;
if ( async && ioctl( s, FIONBIO, (caddr_t)&status ) == -1 ) {
Debug( LDAP_DEBUG_ANY, "FIONBIO ioctl failed on %d\n",
s, 0, 0 );
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#endif /* notyet */
(void)memset( (char *)&sin, 0, sizeof( struct sockaddr_in ));
sin.sin_family = AF_INET;
errno = WSAGetLastError();
#endif
#ifdef notyet
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
#ifdef EAGAIN
if ( errno == EINPROGRESS || errno == EAGAIN ) {
#else /* EAGAIN */
rc = -2;
break;
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#endif /* notyet */
#ifdef LDAP_DEBUG
if ( connected ) {
#ifdef notyet
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
status = 0;
if ( !async && ioctl( s, FIONBIO, (caddr_t)&on ) == -1 ) {
Debug( LDAP_DEBUG_ANY, "FIONBIO ioctl failed on %d\n",
s, 0, 0 );
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#endif /* notyet */
Debug( LDAP_DEBUG_TRACE, "sd %d connected to: %s\n",
#endif /* HAVE_KERBEROS || HAVE_TLS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
/* for UNIX */
struct selectinfo {
fd_set si_readfds;
return( select( tblsize, &sip->si_use_readfds, &sip->si_use_writefds,
NULL, timeout ));
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
LDAPMessage *
ldap_first_reference( LDAP *ld, LDAPMessage *chain )
{
+ assert( ld != NULL );
+ assert( chain != NULL );
+
if ( ld == NULL || chain == NULLMSG ) {
return NULLMSG;
}
: ldap_next_reference( ld, chain );
}
-/* ARGSUSED */
LDAPMessage *
ldap_next_reference( LDAP *ld, LDAPMessage *ref )
{
+ assert( ld != NULL );
+ assert( ref != NULL );
+
if ( ld == NULL || ref == NULLMSG ) {
return NULLMSG;
}
return( NULLMSG );
}
-/* ARGSUSED */
int
ldap_count_references( LDAP *ld, LDAPMessage *chain )
{
int i;
+ assert( ld != NULL );
+ assert( chain != NULL );
+
if ( ld == NULL ) {
return -1;
}
char **refs = NULL;
int rc;
+ assert( ld != NULL );
+ assert( ref != NULL );
+
if( ld == NULL || ref == NULL ||
ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE )
{
#include "ldap-int.h"
#include "lber.h"
-#if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) || defined( LDAP_API_FEATURE_X_OPENLDAP_V2_DNS )
static LDAPConn *find_connection LDAP_P(( LDAP *ld, LDAPServer *srv, int any ));
static void use_connection LDAP_P(( LDAP *ld, LDAPConn *lc ));
static void free_servers LDAP_P(( LDAPServer *srvlist ));
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS || LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
static LDAPServer *dn2servers LDAP_P(( LDAP *ld, char *dn ));
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
static BerElement *re_encode_request LDAP_P(( LDAP *ld, BerElement *origber,
int msgid, char **dnp ));
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
BerElement *
const char *dn,
BerElement *ber )
{
-#if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) || defined( LDAP_API_FEATURE_X_OPENLDAP_V2_DNS )
LDAPServer *servers, *srv;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS || LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 );
if ( ! ber_pvt_sb_in_use(&ld->ld_sb ) ) {
/* not connected yet */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
strdup( ld->ld_defhost )) == NULL ))
}
++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- if ( open_ldap_connection( ld, &ld->ld_sb, ld->ld_defhost,
- ld->ld_defport, &ld->ld_host, 0 ) < 0 )
- {
- ldap_ld_free( ld, 0 );
- ber_free( ber, 1 );
- ld->ld_errno = LDAP_SERVER_DOWN;
- return( -1 );
- }
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-
Debug( LDAP_DEBUG_TRACE,
"ldap_delayed_open successful, ld_host is %s\n",
( ld->ld_host == NULL ) ? "(null)" : ld->ld_host, 0, 0 );
}
-#if !defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) && !defined( LDAP_API_FEATURE_X_OPENLDAP_V2_DNS )
-
- if ( ber_flush( &ld->ld_sb, ber, 1 ) != 0 ) {
- ld->ld_errno = LDAP_SERVER_DOWN;
- return( -1 );
- }
-
- ld->ld_errno = LDAP_SUCCESS;
- return( ld->ld_msgid );
-#else /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS && !LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
if (( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_DNS ) == LDAP_OPT_ON )
&& ldap_is_dns_dn( dn ) )
}
}
#endif /* LDAP_DEBUG */
- } else {
+ } else
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
+ {
/*
* use of DNS is turned off or this is an X.500 DN...
* use our default connection
*/
servers = NULL;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
return( ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, servers,
NULL, 0 ));
-#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS && !LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
}
-#if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS ) || defined( LDAP_API_FEATURE_X_OPENLDAP_V2_DNS )
int
ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
*parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind )
srvlist = nextsrv;
}
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS || LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
/*
* XXX merging of errors in this routine needs to be improved
*/
* all LDAP requests are sequences that start with a message id,
* followed by a sequence that is tagged with the operation code
*/
- if ( ber_scanf( &tmpber, "{i", &along ) != LDAP_TAG_MSGID ||
+ if ( ber_scanf( &tmpber, "{i", /*}*/ &along ) != LDAP_TAG_MSGID ||
( tag = ber_skip_tag( &tmpber, &along )) == LBER_DEFAULT ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
if ( tag == LDAP_REQ_BIND ) {
- rc = ber_printf( ber, "{it{is", msgid, tag, ver, *dnp );
+ rc = ber_printf( ber, "{it{is" /*}}*/, msgid, tag, ver, *dnp );
} else {
- rc = ber_printf( ber, "{it{s", msgid, tag, *dnp );
+ rc = ber_printf( ber, "{it{s" /*}}*/, msgid, tag, *dnp );
}
if ( rc == -1 ) {
if ( ber_write( ber, tmpber.ber_ptr, ( tmpber.ber_end -
tmpber.ber_ptr ), 0 ) != ( tmpber.ber_end - tmpber.ber_ptr ) ||
- ber_printf( ber, "}}" ) == -1 ) {
+ ber_printf( ber, /*{{*/ "}}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return( NULL );
return( lr );
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
static int ldap_mark_abandoned LDAP_P(( LDAP *ld, int msgid ));
static int wait4msg LDAP_P(( LDAP *ld, int msgid, int all, struct timeval *timeout,
LDAPMessage **result ));
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
static int try_read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc,
LDAPMessage **result ));
static unsigned long build_result_ber LDAP_P(( LDAP *ld, BerElement *ber, LDAPRequest *lr ));
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ));
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-static int try_read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb,
- LDAPMessage **result ));
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS )
-static int ldap_select1 LDAP_P(( LDAP *ld, struct timeval *timeout ));
-#endif
/*
struct timeval tv, *tvp;
time_t start_time = 0;
time_t tmp_time;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPConn *lc, *nextlc;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
assert( ld != NULL );
assert( result != NULL );
rc = -2;
while ( rc == -2 ) {
-#ifndef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
- /* hack attack */
- if ( ! ber_pvt_sb_data_ready(&ld->ld_sb) ) {
- rc = ldap_select1( ld, tvp );
-
- if ( rc == 0 || ( rc == -1 && (
- ( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART)
- == LDAP_OPT_OFF )
- || errno != EINTR ))) {
- ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
- LDAP_TIMEOUT);
- return( rc );
- }
-
- }
- if ( rc == -1 ) {
- rc = -2; /* select interrupted: loop */
- } else {
- rc = try_read1msg( ld, msgid, all, &ld->ld_sb, result );
- }
-#else /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#ifdef LDAP_DEBUG
if ( ldap_debug & LDAP_DEBUG_TRACE ) {
ldap_dump_connection( ld, ld->ld_conns, 1 );
}
}
}
-#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( rc == -2 && tvp != NULL ) {
tmp_time = time( NULL );
static int
try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
- LDAPConn *lc,
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- LDAPMessage **result )
+ LDAPConn *lc, LDAPMessage **result )
{
BerElement *ber;
LDAPMessage *new, *l, *prev, *tmp;
long id;
unsigned long tag, len;
int foundit = 0;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPRequest *lr;
BerElement tmpber;
int rc, refer_cnt, hadref, simple_request;
ber = &lc->lconn_ber;
-#else
- assert( ld != NULL );
-
- ber = &ld->ld_ber;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-
Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 );
#if 0
ber_init_w_nullc( &ber, 0 );
ldap_set_ber_options( ld, &ber );
#endif
+
/* get the next message */
if ( (tag = ber_get_next( sb, &len, ber ))
!= LDAP_TAG_MESSAGE ) {
return( -2 ); /* continue looking */
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"no request for response with msgid %ld (tossing)\n",
( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result",
id, lr->lr_origid );
id = lr->lr_origid;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
/* the message type */
if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
return( -1 );
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
refer_cnt = 0;
hadref = simple_request = 0;
rc = -2; /* default is to keep looking (no response found) */
return( rc );
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
/* make a new ldap message */
if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
== NULL ) {
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
static unsigned long
build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr )
{
parentr->lr_res_error : "", parentr->lr_res_matched ?
parentr->lr_res_matched : "" );
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
-
-
-
-#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS )
-
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
- fd_set readfds;
- static int tblsize;
-
- assert( ld != NULL );
-
- if ( tblsize == 0 ) {
-#ifdef HAVE_SYSCONF
- tblsize = sysconf( _SC_OPEN_MAX );
-#elif HAVE_GETDTABLESIZE
- tblsize = getdtablesize();
-#else
- tblsize = FD_SETSIZE;
-#endif
-#ifdef FD_SETSIZE
- if ( tblsize > FD_SETSIZE ) {
- tblsize = FD_SETSIZE;
- }
-#endif /* FD_SETSIZE */
- }
-
- FD_ZERO( &readfds );
- FD_SET( ber_pvt_sb_get_desc(&ld->ld_sb), &readfds );
-
- return( select( tblsize, &readfds, 0, 0, timeout ) );
-}
-#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
int
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
static int
bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
int freeit )
return( LDAP_SUCCESS );
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
int
if ( cldapflg )
cldap_close( ld );
#endif /* LDAP_CONNECTIONLESS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
- if ( !cldapflg )
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- if ( !cldapflg && bound )
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
+
+ if ( !cldapflg ) {
ldap_unbind( ld );
+ }
exit( 0 );
break;
}
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
getline( line, sizeof(line), stdin,
"Recognize and chase referrals (0=no, 1=yes)?" );
if ( atoi( line ) != 0 ) {
ldap_set_rebind_proc( ld, bind_prompt );
}
}
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
break;
case 'O': /* set cache options */
{
LDAPMessage *lm, *next;
int err = LDAP_SUCCESS;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPRequest *lr, *nextlr;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( ld->ld_cldapnaddr == 0 ) {
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
/* free LDAP structure and outstanding requests/responses */
for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
nextlr = lr->lr_next;
while ( ld->ld_conns != NULL ) {
ldap_free_connection( ld, ld->ld_conns, 1, close );
}
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- if ( close ) {
- err = ldap_send_unbind( ld, &ld->ld_sb, sctrls, cctrls );
- ldap_close_connection( &ld->ld_sb );
- }
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
} else {
int i;
ld->ld_abandoned = NULL;
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if ( ld->ld_selectinfo != NULL ) {
ldap_free_select_info( ld->ld_selectinfo );
ld->ld_selectinfo = NULL;
}
-#else
- ber_clear( &(ld->ld_ber), 1 );
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( ld->ld_options.ldo_defbase != NULL ) {
free( ld->ld_options.ldo_defbase );
int err;
LDAPURLDesc *ludp;
BerElement *ber;
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
LDAPServer *srv = NULL;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
if ( ldap_url_parse( url, &ludp ) != 0 ) {
ld->ld_errno = LDAP_PARAM_ERROR;
err = 0;
if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) {
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer )))
== NULL || ( srv->lsrv_host = strdup( ludp->lud_host ==
NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) {
srv->lsrv_port = ludp->lud_port;
}
}
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- ld->ld_errno = LDAP_LOCAL_ERROR;
- err = -1;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
}
if ( err != 0 ) {
ber_free( ber, 1 );
} else {
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
err = ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, srv,
NULL, 1 );
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
- err = ldap_send_initial_request( ld, LDAP_REQ_SEARCH,
- ludp->lud_dn, ber );
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
}
ldap_free_urldesc( ludp );
tber = ber_dup( op->o_ber );
ttag = ber_skip_tag( tber, &tlen );
if ( ber_peek_tag( tber, &tlen ) == LBER_SEQUENCE ) {
- Debug( LDAP_DEBUG_ANY, "bind: version 3.0 detected\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "bind: u-mich v3.0 detected\n", 0, 0, 0 );
conn->c_version = 30;
rc = ber_scanf(ber, "{{iato}}", &version, &cdn, &method, &cred);
} else {
"decoding error" );
return;
}
+
#ifdef LDAP_COMPAT30
if ( conn->c_version == 30 ) {
switch ( method ) {
c->c_struct_state = SLAP_C_UNUSED;
c->c_conn_state = SLAP_C_INVALID;
+#ifdef LDAP_COMPAT30
c->c_version = 0;
+#endif
c->c_protocol = 0;
c->c_starttime = 0;
int c_protocol; /* version of the LDAP protocol used by client */
int c_authtype; /* auth method used to bind c_dn */
#ifdef LDAP_COMPAT
- int c_version; /* for compatibility w/2.0, 3.0 */
+ int c_version; /* for compatibility w/ U-Mich 2.0 & 3.0 */
#endif
Operation *c_ops; /* list of operations being processed */