3 * Copyright (c) 1996 Regents of the University of Michigan.
6 * Redistribution and use in source and binary forms are permitted
7 * provided that this notice is preserved and that due credit is given
8 * to the University of Michigan at Ann Arbor. The name of the University
9 * may not be used to endorse or promote products derived from this
10 * software without specific prior written permission. This software
11 * is provided ``as is'' without express or implied warranty.
15 * ldap_op.c - routines to perform LDAP operations
22 #include <ac/stdlib.h>
25 #include <ac/string.h>
28 #include <ac/unistd.h>
32 #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
33 /* Get LDAP->ld_lberoptions. Must precede slurp.h, both define ldap_debug. */
34 #include "../../libraries/libldap/ldap-int.h"
42 /* Forward references */
43 static struct berval **make_singlevalued_berval LDAP_P(( char *, int ));
44 static int op_ldap_add LDAP_P(( Ri *, Re *, char ** ));
45 static int op_ldap_modify LDAP_P(( Ri *, Re *, char ** ));
46 static int op_ldap_delete LDAP_P(( Ri *, Re *, char ** ));
47 static int op_ldap_modrdn LDAP_P(( Ri *, Re *, char ** ));
48 static LDAPMod *alloc_ldapmod LDAP_P(( void ));
49 static void free_ldapmod LDAP_P(( LDAPMod * ));
50 static void free_ldmarr LDAP_P(( LDAPMod ** ));
51 static int getmodtype LDAP_P(( char * ));
52 static void dump_ldm_array LDAP_P(( LDAPMod ** ));
53 static char **read_krbnames LDAP_P(( Ri * ));
55 static void upcase LDAP_P(( char * ));
57 static int do_bind LDAP_P(( Ri *, int * ));
58 static int do_unbind LDAP_P(( Ri * ));
61 static char *kattrs[] = {"kerberosName", NULL };
62 static struct timeval kst = {30L, 0L};
67 * Determine the type of ldap operation being performed and call the
68 * appropriate routine.
69 * - If successful, returns ERR_DO_LDAP_OK
70 * - If a retryable error occurs, ERR_DO_LDAP_RETRYABLE is returned.
71 * The caller should wait a while and retry the operation.
72 * - If a fatal error occurs, ERR_DO_LDAP_FATAL is returned. The caller
73 * should reject the operation and continue with the next replication
84 int lderr = LDAP_SUCCESS;
90 if ( ri->ri_ldp == NULL ) {
91 rc = do_bind( ri, &lderr );
92 if ( rc != BIND_OK ) {
93 return DO_LDAP_ERR_RETRYABLE;
97 switch ( re->re_changetype ) {
99 lderr = op_ldap_add( ri, re, errmsg );
100 if ( lderr != LDAP_SUCCESS ) {
101 Debug( LDAP_DEBUG_ANY,
102 "Error: ldap_add_s failed adding \"%s\": %s\n",
103 *errmsg ? *errmsg : ldap_err2string( lderr ),
108 lderr = op_ldap_modify( ri, re, errmsg );
109 if ( lderr != LDAP_SUCCESS ) {
110 Debug( LDAP_DEBUG_ANY,
111 "Error: ldap_modify_s failed modifying \"%s\": %s\n",
112 *errmsg ? *errmsg : ldap_err2string( lderr ),
117 lderr = op_ldap_delete( ri, re, errmsg );
118 if ( lderr != LDAP_SUCCESS ) {
119 Debug( LDAP_DEBUG_ANY,
120 "Error: ldap_delete_s failed deleting \"%s\": %s\n",
121 *errmsg ? *errmsg : ldap_err2string( lderr ),
126 lderr = op_ldap_modrdn( ri, re, errmsg );
127 if ( lderr != LDAP_SUCCESS ) {
128 Debug( LDAP_DEBUG_ANY,
129 "Error: ldap_modrdn_s failed modifying %s: %s\n",
130 *errmsg ? *errmsg : ldap_err2string( lderr ),
135 Debug( LDAP_DEBUG_ANY,
136 "Error: do_ldap: bad op \"%d\", dn = \"%s\"\n",
137 re->re_changetype, re->re_dn, 0 );
138 return DO_LDAP_ERR_FATAL;
142 * Analyze return code. If ok, just return. If LDAP_SERVER_DOWN,
143 * we may have been idle long enough that the remote slapd timed
144 * us out. Rebind and try again.
146 if ( lderr == LDAP_SUCCESS ) {
148 } else if ( lderr == LDAP_SERVER_DOWN ) {
149 /* The LDAP server may have timed us out - rebind and try again */
150 (void) do_unbind( ri );
153 return DO_LDAP_ERR_FATAL;
156 return DO_LDAP_ERR_FATAL;
163 * Perform an ldap add operation.
173 int nattrs, rc = 0, i;
174 LDAPMod *ldm, **ldmarr;
181 * Construct a null-terminated array of LDAPMod structs.
184 while ( mi[ i ].mi_type != NULL ) {
185 ldm = alloc_ldapmod();
186 ldmarr = ( LDAPMod ** ) ch_realloc( ldmarr,
187 ( nattrs + 2 ) * sizeof( LDAPMod * ));
188 ldmarr[ nattrs ] = ldm;
189 ldm->mod_op = LDAP_MOD_BVALUES;
190 ldm->mod_type = mi[ i ].mi_type;
192 make_singlevalued_berval( mi[ i ].mi_val, mi[ i ].mi_len );
197 if ( ldmarr != NULL ) {
198 ldmarr[ nattrs ] = NULL;
200 /* Perform the operation */
201 Debug( LDAP_DEBUG_ARGS, "replica %s:%d - add dn \"%s\"\n",
202 ri->ri_hostname, ri->ri_port, re->re_dn );
203 rc = ldap_add_s( ri->ri_ldp, re->re_dn, ldmarr );
205 ldap_get_option( ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &lderr);
208 *errmsg = "No modifications to do";
209 Debug( LDAP_DEBUG_ANY,
210 "Error: op_ldap_add: no mods to do (%s)!\n", re->re_dn, 0, 0 );
212 free_ldmarr( ldmarr );
220 * Perform an ldap modify operation.
222 #define AWAITING_OP -1
231 int state; /* This code is a simple-minded state machine */
232 int nvals; /* Number of values we're modifying */
233 int nops; /* Number of LDAPMod structs in ldmarr */
234 LDAPMod *ldm, **ldmarr;
244 if ( re->re_mods == NULL ) {
245 *errmsg = "No arguments given";
246 Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modify: no arguments\n",
252 * Construct a null-terminated array of LDAPMod structs.
254 for ( mi = re->re_mods, i = 0; mi[ i ].mi_type != NULL; i++ ) {
255 type = mi[ i ].mi_type;
256 value = mi[ i ].mi_val;
257 len = mi[ i ].mi_len;
258 switch ( getmodtype( type )) {
260 state = T_MODSEP; /* Got a separator line "-\n" */
264 ldmarr = ( LDAPMod ** )
265 ch_realloc(ldmarr, (( nops + 2 ) * ( sizeof( LDAPMod * ))));
266 ldmarr[ nops ] = ldm = alloc_ldapmod();
267 ldm->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
268 ldm->mod_type = value;
273 state = T_MODOPREPLACE;
274 ldmarr = ( LDAPMod ** )
275 ch_realloc(ldmarr, (( nops + 2 ) * ( sizeof( LDAPMod * ))));
276 ldmarr[ nops ] = ldm = alloc_ldapmod();
277 ldm->mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
278 ldm->mod_type = value;
283 state = T_MODOPDELETE;
284 ldmarr = ( LDAPMod ** )
285 ch_realloc(ldmarr, (( nops + 2 ) * ( sizeof( LDAPMod * ))));
286 ldmarr[ nops ] = ldm = alloc_ldapmod();
287 ldm->mod_op = LDAP_MOD_DELETE | LDAP_MOD_BVALUES;
288 ldm->mod_type = value;
293 if ( state == AWAITING_OP ) {
294 Debug( LDAP_DEBUG_ANY,
295 "Error: op_ldap_modify: unknown mod type \"%s\"\n",
301 * We should have an attribute: value pair here.
302 * Construct the mod_bvalues part of the ldapmod struct.
304 if ( strcasecmp( type, ldm->mod_type )) {
305 Debug( LDAP_DEBUG_ANY,
306 "Error: malformed modify op, %s: %s (expecting %s:)\n",
307 type, value, ldm->mod_type );
310 ldm->mod_bvalues = ( struct berval ** )
311 ch_realloc( ldm->mod_bvalues,
312 ( nvals + 2 ) * sizeof( struct berval * ));
313 ldm->mod_bvalues[ nvals + 1 ] = NULL;
314 ldm->mod_bvalues[ nvals ] = ( struct berval * )
315 ch_malloc( sizeof( struct berval ));
316 ldm->mod_bvalues[ nvals ]->bv_val = value;
317 ldm->mod_bvalues[ nvals ]->bv_len = len;
321 ldmarr[ nops ] = NULL;
324 /* Actually perform the LDAP operation */
325 Debug( LDAP_DEBUG_ARGS, "replica %s:%d - modify dn \"%s\"\n",
326 ri->ri_hostname, ri->ri_port, re->re_dn );
327 rc = ldap_modify_s( ri->ri_ldp, re->re_dn, ldmarr );
329 free_ldmarr( ldmarr );
337 * Perform an ldap delete operation.
348 Debug( LDAP_DEBUG_ARGS, "replica %s:%d - delete dn \"%s\"\n",
349 ri->ri_hostname, ri->ri_port, re->re_dn );
350 rc = ldap_delete_s( ri->ri_ldp, re->re_dn );
359 * Perform an ldap modrdn operation.
361 #define GOT_NEWRDN 0x1
362 #define GOT_DELOLDRDN 0x2
363 #define GOT_NEWSUP 0x4
365 #define GOT_MODDN_REQ (GOT_NEWRDN|GOT_DELOLDRDN)
366 #define GOT_ALL_MODDN(f) (((f) & GOT_MODDN_REQ) == GOT_MODDN_REQ)
383 if ( re->re_mods == NULL ) {
384 *errmsg = "No arguments given";
385 Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modrdn: no arguments\n",
391 * Get the arguments: should see newrdn: and deleteoldrdn: args.
393 for ( mi = re->re_mods, i = 0; mi[ i ].mi_type != NULL; i++ ) {
394 if ( !strcmp( mi[ i ].mi_type, T_NEWRDNSTR )) {
395 if( state & GOT_NEWRDN ) {
396 Debug( LDAP_DEBUG_ANY,
397 "Error: op_ldap_modrdn: multiple newrdn arg \"%s\"\n",
398 mi[ i ].mi_val, 0, 0 );
399 *errmsg = "Multiple newrdn argument";
403 newrdn = mi[ i ].mi_val;
406 } else if ( !strcmp( mi[ i ].mi_type, T_DELOLDRDNSTR )) {
407 if( state & GOT_DELOLDRDN ) {
408 Debug( LDAP_DEBUG_ANY,
409 "Error: op_ldap_modrdn: multiple deleteoldrdn arg \"%s\"\n",
410 mi[ i ].mi_val, 0, 0 );
411 *errmsg = "Multiple newrdn argument";
415 state |= GOT_DELOLDRDN;
416 if ( !strcmp( mi[ i ].mi_val, "0" )) {
418 } else if ( !strcmp( mi[ i ].mi_val, "1" )) {
421 Debug( LDAP_DEBUG_ANY,
422 "Error: op_ldap_modrdn: bad deleteoldrdn arg \"%s\"\n",
423 mi[ i ].mi_val, 0, 0 );
424 *errmsg = "Incorrect argument to deleteoldrdn";
428 } else if ( !strcmp( mi[ i ].mi_type, T_NEWSUPSTR )) {
429 if( state & GOT_NEWSUP ) {
430 Debug( LDAP_DEBUG_ANY,
431 "Error: op_ldap_modrdn: multiple newsuperior arg \"%s\"\n",
432 mi[ i ].mi_val, 0, 0 );
433 *errmsg = "Multiple newrdn argument";
437 newrdn = mi[ i ].mi_val;
441 Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modrdn: bad type \"%s\"\n",
442 mi[ i ].mi_type, 0, 0 );
443 *errmsg = "Bad value in replication log entry";
449 * Punt if we don't have all the args.
451 if ( GOT_ALL_MODDN(state) ) {
452 Debug( LDAP_DEBUG_ANY, "Error: op_ldap_modrdn: missing arguments\n",
454 *errmsg = "Missing argument: requires \"newrdn\" and \"deleteoldrdn\"";
459 if ( ldap_debug & LDAP_DEBUG_ARGS ) {
462 sprintf( buf, "%s:%d", ri->ri_hostname, ri->ri_port );
463 buf2 = (char *) ch_malloc( strlen( re->re_dn ) + strlen( mi->mi_val )
465 sprintf( buf2, "(\"%s\" -> \"%s\")", re->re_dn, mi->mi_val );
466 Debug( LDAP_DEBUG_ARGS,
467 "replica %s - modify rdn %s (flag: %d)\n",
468 buf, buf2, drdnflag );
471 #endif /* LDAP_DEBUG */
474 rc = ldap_rename2_s( ri->ri_ldp, re->re_dn, mi->mi_val, drdnflag, newsup );
476 ldap_get_option( ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &lderr);
483 * Allocate and initialize an ldapmod struct.
486 alloc_ldapmod( void )
490 ldm = ( struct ldapmod * ) ch_malloc( sizeof ( struct ldapmod ));
491 ldm->mod_type = NULL;
492 ldm->mod_bvalues = ( struct berval ** ) NULL;
499 * Free an ldapmod struct associated mod_bvalues. NOTE - it is assumed
500 * that mod_bvalues and mod_type contain pointers to the same block of memory
501 * pointed to by the repl struct. Therefore, it's not freed here.
512 if ( ldm->mod_bvalues != NULL ) {
513 for ( i = 0; ldm->mod_bvalues[ i ] != NULL; i++ ) {
514 free( ldm->mod_bvalues[ i ] );
516 free( ldm->mod_bvalues );
524 * Free an an array of LDAPMod pointers and the LDAPMod structs they point
533 for ( i = 0; ldmarr[ i ] != NULL; i++ ) {
534 free_ldapmod( ldmarr[ i ] );
541 * Create a berval with a single value.
543 static struct berval **
544 make_singlevalued_berval(
550 p = ( struct berval ** ) ch_malloc( 2 * sizeof( struct berval * ));
551 p[ 0 ] = ( struct berval * ) ch_malloc( sizeof( struct berval ));
553 p[ 0 ]->bv_val = value;
554 p[ 0 ]->bv_len = len;
560 * Given a modification type (string), return an enumerated type.
561 * Avoids ugly copy in op_ldap_modify - lets us use a switch statement
568 if ( !strcmp( type, T_MODSEPSTR )) {
571 if ( !strcmp( type, T_MODOPADDSTR )) {
572 return( T_MODOPADD );
574 if ( !strcmp( type, T_MODOPREPLACESTR )) {
575 return( T_MODOPREPLACE );
577 if ( !strcmp( type, T_MODOPDELETESTR )) {
578 return( T_MODOPDELETE );
585 * Perform an LDAP unbind operation. If replica is NULL, or the
586 * repl_ldp is NULL, just return LDAP_SUCCESS. Otherwise, unbind,
587 * set the ldp to NULL, and return the result of the unbind call.
594 int rc = LDAP_SUCCESS;
596 if (( ri != NULL ) && ( ri->ri_ldp != NULL )) {
597 rc = ldap_unbind( ri->ri_ldp );
598 if ( rc != LDAP_SUCCESS ) {
599 Debug( LDAP_DEBUG_ANY,
600 "Error: do_unbind: ldap_unbind failed for %s:%d: %s\n",
601 ri->ri_hostname, ri->ri_port, ldap_err2string( rc ) );
611 * Perform an LDAP bind operation to the replication site given
612 * by replica. If replica->repl_ldp is non-NULL, then we unbind
613 * from the replica before rebinding. It should be safe to call
614 * this to re-connect if the replica's connection goes away
617 * Returns 0 on success, -1 if an LDAP error occurred, and a return
618 * code > 0 if some other error occurred, e.g. invalid bind method.
619 * If an LDAP error occurs, the LDAP error is returned in lderr.
633 char *skrbnames[ 2 ];
634 char realm[ REALM_SZ ];
635 char name[ ANAME_SZ ];
636 char instance[ INST_SZ ];
637 #endif /* HAVE_KERBEROS */
642 Debug( LDAP_DEBUG_ANY, "Error: do_bind: null ri ptr\n", 0, 0, 0 );
643 return( BIND_ERR_BADRI );
646 if ( ri->ri_ldp != NULL ) {
647 ldrc = ldap_unbind( ri->ri_ldp );
648 if ( ldrc != LDAP_SUCCESS ) {
649 Debug( LDAP_DEBUG_ANY,
650 "Error: do_bind: ldap_unbind failed: %s\n",
651 ldap_err2string( ldrc ), 0, 0 );
656 Debug( LDAP_DEBUG_ARGS, "Initializing session to %s:%d\n",
657 ri->ri_hostname, ri->ri_port, 0 );
658 ri->ri_ldp = ldap_init( ri->ri_hostname, ri->ri_port );
659 if ( ri->ri_ldp == NULL ) {
660 Debug( LDAP_DEBUG_ANY, "Error: ldap_init(%s, %d) failed: %s\n",
661 ri->ri_hostname, ri->ri_port, sys_errlist[ errno ] );
662 return( BIND_ERR_OPEN );
666 * Disable string translation if enabled by default.
667 * The replication log is written in the internal format,
668 * so this would do another translation, breaking havoc.
670 #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
671 ri->ri_ldp->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS;
672 #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
675 * Set ldap library options to (1) not follow referrals, and
676 * (2) restart the select() system call.
678 ldap_set_option(ri->ri_ldp, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
679 ldap_set_option(ri->ri_ldp, LDAP_OPT_RESTART, LDAP_OPT_ON);
681 switch ( ri->ri_bind_method ) {
683 #ifndef HAVE_KERBEROS
684 Debug( LDAP_DEBUG_ANY,
685 "Error: Kerberos bind for %s:%d, but not compiled w/kerberos\n",
686 ri->ri_hostname, ri->ri_port, 0 );
687 return( BIND_ERR_KERBEROS_FAILED );
688 #else /* HAVE_KERBEROS */
690 * Bind using kerberos.
691 * If "bindprincipal" was given in the config file, then attempt
692 * to get a TGT for that principal (via the srvtab file). If only
693 * a binddn was given, then we need to read that entry to get
694 * the kerberosName attributes, and try to get a TGT for one
695 * of them. All are tried. The first one which succeeds is
696 * returned. XXX It might be a good idea to just require a
697 * bindprincipal. Reading the entry every time might be a significant
698 * amount of overhead, if the connection is closed between most
702 if ( ri->ri_principal != NULL ) {
703 skrbnames[ 0 ] = ri->ri_principal;
704 skrbnames[ 1 ] = NULL;
705 krbnames = skrbnames;
707 krbnames = read_krbnames( ri );
710 if (( krbnames == NULL ) || ( krbnames[ 0 ] == NULL )) {
711 Debug( LDAP_DEBUG_ANY,
712 "Error: Can't find krbname for binddn \"%s\"\n",
713 ri->ri_bind_dn, 0, 0 );
714 retval = BIND_ERR_KERBEROS_FAILED;
718 * Now we've got one or more kerberos principals. See if any
719 * of them are in the srvtab file.
722 for ( kni = 0; krbnames[ kni ] != NULL; kni++ ) {
723 rc = kname_parse( name, instance, realm, krbnames[ kni ]);
724 if ( rc != KSUCCESS ) {
728 rc = krb_get_svc_in_tkt( name, instance, realm, "krbtgt", realm,
730 if ( rc != KSUCCESS) {
731 Debug( LDAP_DEBUG_ANY, "Error: Can't get TGT for %s: %s\n",
732 krbnames[ kni ], krb_err_txt[ rc ], 0 );
739 Debug( LDAP_DEBUG_ANY,
740 "Error: Could not obtain TGT for DN \"%s\"\n",
741 ri->ri_bind_dn, 0, 0 );
742 retval = BIND_ERR_KERBEROS_FAILED;
746 * We've got a TGT. Do a kerberos bind.
748 Debug( LDAP_DEBUG_ARGS, "bind to %s:%d as %s (kerberos)\n",
749 ri->ri_hostname, ri->ri_port, ri->ri_bind_dn );
750 ldrc = ldap_kerberos_bind_s( ri->ri_ldp, ri->ri_bind_dn );
751 ri->ri_principal = strdup( krbnames[ kni ] );
752 if ( ldrc != LDAP_SUCCESS ) {
753 Debug( LDAP_DEBUG_ANY, "Error: kerberos bind for %s:%dfailed: %s\n",
754 ri->ri_hostname, ri->ri_port, ldap_err2string( ldrc ));
756 retval = BIND_ERR_KERBEROS_FAILED;
759 kexit: if ( krbnames != NULL ) {
760 ldap_value_free( krbnames );
764 #endif /* HAVE_KERBEROS */
767 * Bind with a plaintext password.
769 Debug( LDAP_DEBUG_ARGS, "bind to %s:%d as %s (simple)\n",
770 ri->ri_hostname, ri->ri_port, ri->ri_bind_dn );
771 ldrc = ldap_simple_bind_s( ri->ri_ldp, ri->ri_bind_dn,
773 if ( ldrc != LDAP_SUCCESS ) {
774 Debug( LDAP_DEBUG_ANY,
775 "Error: ldap_simple_bind_s for %s:%d failed: %s\n",
776 ri->ri_hostname, ri->ri_port, ldap_err2string( ldrc ));
778 return( BIND_ERR_SIMPLE_FAILED );
784 Debug( LDAP_DEBUG_ANY,
785 "Error: do_bind: unknown auth type \"%d\" for %s:%d\n",
786 ri->ri_bind_method, ri->ri_hostname, ri->ri_port );
787 return( BIND_ERR_BAD_ATYPE );
796 * For debugging. Print the contents of an ldmarr array.
808 for ( i = 0; ldmarr[ i ] != NULL; i++ ) {
810 Debug( LDAP_DEBUG_TRACE,
811 "Trace (%ld): *** ldmarr[ %d ] contents:\n",
812 (long) getpid(), i, 0 );
813 Debug( LDAP_DEBUG_TRACE,
814 "Trace (%ld): *** ldm->mod_op: %d\n",
815 (long) getpid(), ldm->mod_op, 0 );
816 Debug( LDAP_DEBUG_TRACE,
817 "Trace (%ld): *** ldm->mod_type: %s\n",
818 (long) getpid(), ldm->mod_type, 0 );
819 if ( ldm->mod_bvalues != NULL ) {
820 for ( j = 0; ( b = ldm->mod_bvalues[ j ] ) != NULL; j++ ) {
821 msgbuf = ch_malloc( b->bv_len + 512 );
822 sprintf( msgbuf, "***** bv[ %d ] len = %ld, val = <%s>",
823 j, b->bv_len, b->bv_val );
824 Debug( LDAP_DEBUG_TRACE,
825 "Trace (%ld):%s\n", (long) getpid(), msgbuf, 0 );
834 * Get the kerberos names from the binddn for "replica" via an ldap search.
835 * Returns a null-terminated array of char *, or NULL if the entry could
836 * not be found or there were no kerberosName attributes. The caller is
837 * responsible for freeing the returned array and strings it points to.
847 LDAPMessage *result, *entry;
849 /* First need to bind as NULL */
850 rc = ldap_simple_bind_s( ri->ri_ldp, NULL, NULL );
851 if ( rc != LDAP_SUCCESS ) {
852 Debug( LDAP_DEBUG_ANY,
853 "Error: null bind failed getting krbnames for %s:%d: %s\n",
854 ri->ri_hostname, ri->ri_port, ldap_err2string( rc ));
857 rc = ldap_search_st( ri->ri_ldp, ri->ri_bind_dn, LDAP_SCOPE_BASE,
858 "objectclass=*", kattrs, 0, &kst, &result );
859 if ( rc != LDAP_SUCCESS ) {
860 Debug( LDAP_DEBUG_ANY,
861 "Error: search failed getting krbnames for %s:%d: %s\n",
862 ri->ri_hostname, ri->ri_port, ldap_err2string( rc ));
865 ne = ldap_count_entries( ri->ri_ldp, result );
867 Debug( LDAP_DEBUG_ANY,
868 "Error: Can't find entry \"%s\" for %s:%d kerberos bind\n",
869 ri->ri_bind_dn, ri->ri_hostname, ri->ri_port );
873 Debug( LDAP_DEBUG_ANY,
874 "Error: Kerberos binddn \"%s\" for %s:%dis ambiguous\n",
875 ri->ri_bind_dn, ri->ri_hostname, ri->ri_port );
878 entry = ldap_first_entry( ri->ri_ldp, result );
879 if ( entry == NULL ) {
880 Debug( LDAP_DEBUG_ANY,
881 "Error: Can't find \"%s\" for kerberos binddn for %s:%d\n",
882 ri->ri_bind_dn, ri->ri_hostname, ri->ri_port );
885 krbnames = ldap_get_values( ri->ri_ldp, entry, "kerberosName" );
886 ldap_msgfree( result );
903 for ( p = s; ( p != NULL ) && ( *p != '\0' ); p++ ) {
904 *p = TOUPPER( (unsigned char) *p );
908 #endif /* HAVE_KERBEROS */