mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-28 18:49:34 -05:00
ldap.h:
added comments removed LDAP_MAX_ATTR_LEN removed LDAP_COMPAT* from <ldap.h> but not code. move LDAP_DEFAULT_REFHOPCOUNT to ldap-int.h added experimental options macros added LDAP_CONTROL_REFERRALS macros libldap: Replace ld_attrbuffer with per use allocated attributed. ldap_first/next_attribute attributes now must be freed (as per draft). unifdef -DLDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
This commit is contained in:
parent
6b45dde2e6
commit
22d98c85c3
20 changed files with 109 additions and 274 deletions
|
|
@ -69,13 +69,12 @@ LDAP_BEGIN_DECL
|
|||
#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
|
||||
|
|
@ -96,12 +95,17 @@ LDAP_BEGIN_DECL
|
|||
#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)
|
||||
|
|
@ -120,7 +124,7 @@ typedef struct ldapapiinfo {
|
|||
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 */
|
||||
|
|
@ -133,7 +137,15 @@ typedef struct ldapcontrol {
|
|||
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
|
||||
|
|
@ -350,7 +362,7 @@ typedef struct ldapmod {
|
|||
#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
|
||||
|
|
@ -389,9 +401,6 @@ typedef struct ldapmod {
|
|||
#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,
|
||||
|
|
@ -477,11 +486,14 @@ typedef struct ldap_url_desc {
|
|||
} 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;
|
||||
|
||||
/*
|
||||
|
|
@ -791,11 +803,17 @@ ldap_delete_s LDAP_P((
|
|||
* 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 ));
|
||||
|
||||
|
|
|
|||
|
|
@ -86,9 +86,7 @@ do_abandon(
|
|||
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:
|
||||
|
|
@ -100,7 +98,6 @@ do_abandon(
|
|||
|
||||
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 */
|
||||
|
|
@ -123,7 +120,6 @@ do_abandon(
|
|||
sendabandon = 0;
|
||||
}
|
||||
}
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
|
||||
if ( ldap_msgdelete( ld, msgid ) == 0 ) {
|
||||
ld->ld_errno = LDAP_SUCCESS;
|
||||
|
|
@ -178,12 +174,9 @@ do_abandon(
|
|||
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +190,6 @@ do_abandon(
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
||||
if ( lr != NULL ) {
|
||||
if ( sendabandon ) {
|
||||
ldap_free_connection( ld, lr->lr_conn, 0, 1 );
|
||||
|
|
@ -206,8 +198,6 @@ do_abandon(
|
|||
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) ))
|
||||
|
|
|
|||
|
|
@ -117,11 +117,9 @@ ldap_bind_s(
|
|||
}
|
||||
|
||||
|
||||
#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 */
|
||||
|
|
|
|||
|
|
@ -156,9 +156,7 @@ cldap_open( char *host, int port )
|
|||
}
|
||||
|
||||
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 );
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@
|
|||
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 );
|
||||
|
||||
|
|
@ -41,8 +45,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
|
|||
* 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 );
|
||||
|
|
@ -50,25 +53,27 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
|
|||
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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ char **
|
|||
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 );
|
||||
|
|
@ -35,8 +34,7 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
|||
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 );
|
||||
}
|
||||
|
|
@ -46,16 +44,22 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
|||
|
||||
/* 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.
|
||||
|
|
@ -73,9 +77,8 @@ struct berval **
|
|||
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 );
|
||||
|
|
@ -83,8 +86,7 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
|||
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 );
|
||||
}
|
||||
|
|
@ -94,8 +96,10 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
|||
|
||||
/* 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 );
|
||||
}
|
||||
|
|
@ -104,6 +108,9 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
|
|||
break;
|
||||
}
|
||||
|
||||
free( attr );
|
||||
attr = NULL;
|
||||
|
||||
/*
|
||||
* if we get this far, we've found the attribute and are sitting
|
||||
* just before the set of values.
|
||||
|
|
|
|||
|
|
@ -306,10 +306,7 @@ void openldap_ldap_initialize( void )
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -262,11 +262,7 @@ ldap_get_kerberosv4_credentials(
|
|||
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 ) {
|
||||
|
|
|
|||
|
|
@ -37,16 +37,17 @@ LDAP_BEGIN_DECL
|
|||
#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
|
||||
|
|
@ -102,7 +103,6 @@ struct ldapoptions {
|
|||
LDAP_BOOLEANS ldo_booleans; /* boolean options */
|
||||
};
|
||||
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
||||
/*
|
||||
* structure for tracking LDAP server host, ports, DNs, etc.
|
||||
*/
|
||||
|
|
@ -156,7 +156,6 @@ typedef struct ldapreq {
|
|||
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
|
||||
|
|
@ -220,35 +219,27 @@ struct ldap {
|
|||
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 */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -326,7 +317,6 @@ void ldap_close_connection( Sockbuf *sb );
|
|||
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 );
|
||||
|
|
@ -335,7 +325,6 @@ void ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
|
|||
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 */
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -346,8 +335,6 @@ int ldap_send_initial_request( LDAP *ld, unsigned long msgtype,
|
|||
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 );
|
||||
|
|
@ -358,12 +345,9 @@ void ldap_free_request( LDAP *ld, LDAPRequest *lr );
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ LDAP *
|
|||
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 );
|
||||
|
||||
|
|
@ -49,7 +47,6 @@ ldap_open( LDAP_CONST char *host, int port )
|
|||
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 )) {
|
||||
|
|
@ -67,14 +64,6 @@ ldap_open( LDAP_CONST char *host, int port )
|
|||
}
|
||||
++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 );
|
||||
|
||||
|
|
@ -173,7 +162,6 @@ ldap_init( LDAP_CONST char *defhost, int defport )
|
|||
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 ) {
|
||||
|
|
@ -183,7 +171,6 @@ ldap_init( LDAP_CONST char *defhost, int defport )
|
|||
WSACleanup( );
|
||||
return( NULL );
|
||||
}
|
||||
#endif
|
||||
|
||||
if(defport != 0) {
|
||||
ld->ld_defport = defport;
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address,
|
|||
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 */
|
||||
|
|
@ -89,13 +87,11 @@ ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address,
|
|||
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;
|
||||
|
|
@ -114,7 +110,6 @@ ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address,
|
|||
errno = WSAGetLastError();
|
||||
#endif
|
||||
#ifdef notyet
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
||||
#ifdef EAGAIN
|
||||
if ( errno == EINPROGRESS || errno == EAGAIN ) {
|
||||
#else /* EAGAIN */
|
||||
|
|
@ -125,7 +120,6 @@ ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address,
|
|||
rc = -2;
|
||||
break;
|
||||
}
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
#endif /* notyet */
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
|
|
@ -145,13 +139,11 @@ ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address,
|
|||
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",
|
||||
|
|
@ -216,7 +208,6 @@ ldap_host_connected_to( Sockbuf *sb )
|
|||
#endif /* HAVE_KERBEROS || HAVE_TLS */
|
||||
|
||||
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
||||
/* for UNIX */
|
||||
struct selectinfo {
|
||||
fd_set si_readfds;
|
||||
|
|
@ -339,4 +330,3 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
|
|||
return( select( tblsize, &sip->si_use_readfds, &sip->si_use_writefds,
|
||||
NULL, timeout ));
|
||||
}
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@
|
|||
LDAPMessage *
|
||||
ldap_first_reference( LDAP *ld, LDAPMessage *chain )
|
||||
{
|
||||
assert( ld != NULL );
|
||||
assert( chain != NULL );
|
||||
|
||||
if ( ld == NULL || chain == NULLMSG ) {
|
||||
return NULLMSG;
|
||||
}
|
||||
|
|
@ -31,10 +34,12 @@ ldap_first_reference( LDAP *ld, LDAPMessage *chain )
|
|||
: 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;
|
||||
}
|
||||
|
|
@ -52,12 +57,14 @@ ldap_next_reference( LDAP *ld, LDAPMessage *ref )
|
|||
return( NULLMSG );
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
ldap_count_references( LDAP *ld, LDAPMessage *chain )
|
||||
{
|
||||
int i;
|
||||
|
||||
assert( ld != NULL );
|
||||
assert( chain != NULL );
|
||||
|
||||
if ( ld == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -83,6 +90,9 @@ ldap_parse_reference(
|
|||
char **refs = NULL;
|
||||
int rc;
|
||||
|
||||
assert( ld != NULL );
|
||||
assert( ref != NULL );
|
||||
|
||||
if( ld == NULL || ref == NULL ||
|
||||
ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,21 +23,16 @@
|
|||
#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 *
|
||||
|
|
@ -78,16 +73,13 @@ ldap_send_initial_request(
|
|||
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 ))
|
||||
|
|
@ -111,34 +103,12 @@ ldap_send_initial_request(
|
|||
}
|
||||
++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 ) )
|
||||
|
|
@ -162,25 +132,22 @@ ldap_send_initial_request(
|
|||
}
|
||||
}
|
||||
#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 )
|
||||
|
|
@ -615,10 +582,8 @@ free_servers( LDAPServer *srvlist )
|
|||
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
|
||||
*/
|
||||
|
|
@ -828,7 +793,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
|
|||
* 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 );
|
||||
|
|
@ -859,9 +824,9 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
|
|||
}
|
||||
|
||||
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 ) {
|
||||
|
|
@ -871,7 +836,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
|
|||
|
||||
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 );
|
||||
|
|
@ -902,7 +867,6 @@ ldap_find_request_by_msgid( LDAP *ld, int msgid )
|
|||
|
||||
return( lr );
|
||||
}
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
|
||||
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
|
||||
|
|
|
|||
|
|
@ -27,18 +27,10 @@ static int ldap_abandoned LDAP_P(( LDAP *ld, int msgid ));
|
|||
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
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -152,9 +144,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
|
|||
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 );
|
||||
|
|
@ -179,27 +169,6 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
|
|||
|
||||
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 );
|
||||
|
|
@ -253,7 +222,6 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
|
||||
if ( rc == -2 && tvp != NULL ) {
|
||||
tmp_time = time( NULL );
|
||||
|
|
@ -275,17 +243,13 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
|
|||
|
||||
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;
|
||||
|
|
@ -296,18 +260,13 @@ try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
|
|||
|
||||
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 ) {
|
||||
|
|
@ -341,7 +300,6 @@ try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
|
|||
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",
|
||||
|
|
@ -354,7 +312,6 @@ try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
|
|||
( 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 ) {
|
||||
|
|
@ -362,7 +319,6 @@ try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
|
|||
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) */
|
||||
|
|
@ -459,7 +415,6 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
|
|||
return( rc );
|
||||
}
|
||||
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
/* make a new ldap message */
|
||||
if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
|
||||
== NULL ) {
|
||||
|
|
@ -552,7 +507,6 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
|
|||
}
|
||||
|
||||
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
||||
static unsigned long
|
||||
build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr )
|
||||
{
|
||||
|
|
@ -617,44 +571,9 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, 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
|
||||
ldap_msgtype( LDAPMessage *lm )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -226,7 +226,6 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
|
|||
}
|
||||
|
||||
|
||||
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
||||
static int
|
||||
bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
|
||||
int freeit )
|
||||
|
|
@ -261,7 +260,6 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
|
|||
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
|
||||
|
||||
int
|
||||
|
|
@ -545,12 +543,10 @@ main( int argc, char **argv )
|
|||
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;
|
||||
|
||||
|
|
@ -792,7 +788,6 @@ main( int argc, char **argv )
|
|||
}
|
||||
#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 ) {
|
||||
|
|
@ -803,7 +798,6 @@ main( int argc, char **argv )
|
|||
ldap_set_rebind_proc( ld, bind_prompt );
|
||||
}
|
||||
}
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
|
||||
break;
|
||||
|
||||
case 'O': /* set cache options */
|
||||
|
|
|
|||
|
|
@ -47,12 +47,9 @@ ldap_ld_free(
|
|||
{
|
||||
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;
|
||||
|
|
@ -63,12 +60,6 @@ ldap_ld_free(
|
|||
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;
|
||||
|
||||
|
|
@ -120,14 +111,10 @@ ldap_ld_free(
|
|||
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 );
|
||||
|
|
|
|||
|
|
@ -255,9 +255,7 @@ ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly )
|
|||
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;
|
||||
|
|
@ -275,7 +273,6 @@ ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly )
|
|||
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 ) {
|
||||
|
|
@ -291,22 +288,13 @@ ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly )
|
|||
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 );
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ do_bind(
|
|||
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 {
|
||||
|
|
@ -83,6 +83,7 @@ do_bind(
|
|||
"decoding error" );
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( conn->c_version == 30 ) {
|
||||
switch ( method ) {
|
||||
|
|
|
|||
|
|
@ -328,7 +328,9 @@ connection_destroy( Connection *c )
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ typedef struct slap_conn {
|
|||
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 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue