Lines Matching refs:ld

62 static LDAPConn *find_connection( LDAP *ld, LDAPServer *srv, int any );
63 static void use_connection( LDAP *ld, LDAPConn *lc );
74 static LDAPServer *dn2servers( LDAP *ld, char *dn );
82 alloc_ber_with_options( LDAP *ld )
86 if (( ber = ber_alloc_t( ld->ld_lberoptions )) == NULLBER ) {
87 ld->ld_errno = LDAP_NO_MEMORY;
90 set_ber_options( ld, ber );
99 set_ber_options( LDAP *ld, BerElement *ber )
101 ber->ber_options = ld->ld_lberoptions;
103 if (( ld->ld_lberoptions & LBER_TRANSLATE_STRINGS ) != 0 ) {
105 ld->ld_lber_encode_translate_proc,
106 ld->ld_lber_decode_translate_proc );
113 send_initial_request( LDAP *ld, unsigned int msgtype, char *dn,
120 LOCK_LDAP(ld);
125 if (( ld->ld_options & LDAP_OPT_DNS ) != 0 && ldap_is_dns_dn( dn )) {
126 if (( servers = dn2servers( ld, dn )) == NULL ) {
129 UNLOCK_LDAP(ld);
160 UNLOCK_LDAP(ld);
162 rv = send_server_request( ld, ber, ld->ld_msgid, NULL, servers,
168 send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
175 LOCK_LDAP(ld);
179 ld->ld_errno = LDAP_SUCCESS; /* optimistic */
188 if (ld->ld_defconn == NULL){ /* Not connected yet on the default connection, ie init was called not open */
189 if ((err = open_default_ldap_connection(ld)) != LDAP_SUCCESS){
190 ld->ld_errno = err;
196 UNLOCK_LDAP(ld);
202 lc = ld->ld_defconn;
204 if (( lc = find_connection( ld, srvlist, 1 )) ==
206 lc = new_connection( ld, &srvlist, 0, 1, bind );
214 if ( ld->ld_errno == LDAP_SUCCESS ) {
215 ld->ld_errno = LDAP_SERVER_DOWN;
221 UNLOCK_LDAP(ld);
226 use_connection( ld, lc );
229 ld->ld_errno = LDAP_NO_MEMORY;
230 free_connection( ld, lc, 0, 0 );
233 UNLOCK_LDAP(ld);
253 if (( lr->lr_next = ld->ld_requests ) != NULL ) {
256 ld->ld_requests = lr;
266 mark_select_write( ld, lc->lconn_sb );
269 ld->ld_errno = LDAP_SERVER_DOWN;
270 free_request( ld, lr );
271 free_connection( ld, lc, 0, 0 );
273 UNLOCK_LDAP(ld);
287 mark_select_read( ld, lc->lconn_sb );
290 ld->ld_errno = LDAP_SUCCESS;
292 UNLOCK_LDAP(ld);
299 new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
316 ld->ld_errno = LDAP_NO_MEMORY;
321 LOCK_LDAP(ld);
323 lc->lconn_sb = ( use_ldsb ) ? &ld->ld_sb : sb;
329 if ( open_ldap_connection( ld, lc->lconn_sb,
342 ld->ld_errno = LDAP_SERVER_DOWN;
344 UNLOCK_LDAP(ld);
358 lc->lconn_next = ld->ld_conns;
359 ld->ld_conns = lc;
372 if ( ld->ld_version == LDAP_VERSION3 && ld->ld_rebindproc == NULL){
376 if ( ld->ld_rebindproc == NULL ) {
380 if (( err = (*ld->ld_rebindproc)( ld, &binddn, &passwd,
381 &authmethod, 0, ld->ld_rebind_extra_arg )) == LDAP_SUCCESS ) {
384 ld->ld_errno = err;
390 savedefconn = ld->ld_defconn;
391 ld->ld_defconn = lc;
394 if ( ldap_bind_s( ld, binddn, passwd, authmethod ) !=
399 ld->ld_defconn = savedefconn;
403 (*ld->ld_rebindproc)( ld, &binddn, &passwd,
404 &authmethod, 1, ld->ld_rebind_extra_arg );
408 free_connection( ld, lc, 1, 0 );
415 UNLOCK_LDAP(ld);
422 find_connection( LDAP *ld, LDAPServer *srv, int any )
432 LOCK_LDAP(ld);
434 for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
441 UNLOCK_LDAP(ld);
452 UNLOCK_LDAP(ld);
460 use_connection( LDAP *ld, LDAPConn *lc )
468 free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
476 mark_select_clear( ld, lc->lconn_sb );
478 send_unbind( ld, lc->lconn_sb );
487 for ( tmplc = ld->ld_conns; tmplc != NULL;
491 ld->ld_conns = tmplc->lconn_next;
502 if ( lc->lconn_sb != &ld->ld_sb ) {
518 dump_connection( LDAP *ld, LDAPConn *lconns, int all )
529 &ld->ld_sb ) ? " (default)" : "" );
545 dump_requests_and_responses( LDAP *ld )
551 if (( lr = ld->ld_requests ) == NULL ) {
567 LOCK_RESPONSE(ld);
569 if (( lm = ld->ld_responses ) == NULLMSG ) {
585 UNLOCK_RESPONSE(ld);
592 free_request( LDAP *ld, LDAPRequest *lr )
606 free_request( ld, tmplr );
611 ld->ld_requests = lr->lr_next;
671 * nsldapi_connection_lost_nolock() resets "ld" to a non-connected, known
677 nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb )
687 for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
700 dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */
713 ld->ld_errno = LDAP_NO_MEMORY;
774 ld->ld_errno = LDAP_SERVER_DOWN;