1 /* centipede.c - generate and install indexing information (view w/tabstop=4) */
11 #include <ac/unistd.h> /* get link(), unlink() */
16 #include <ldapconfig.h>
19 #define DEFAULT_LDAPFILTER "(objectclass=*)"
21 #define CENTROID_VALUE 1
22 #define CENTROID_WORD 2
24 #define CENTROID_RELATIVE 1
25 #define CENTROID_FULL 2
27 #define WORD_BREAKS " -',.()!;:&$%*\"/\\+_<>=?[]|^~"
40 int srcldapauthmethod;
41 int destldapauthmethod;
45 static LDAP *start_ldap_search(char *ldapsrcurl, char *ldapfilter, char **attrs);
46 static LDAP *bind_to_destination_ldap(char *ldapsrcurl, char *ldapdesturl);
47 static int create_tmp_files(char **attrs, char ***tmpfile, LDBM **ldbm);
48 static int generate_new_centroids(LDAP *ld, char **attrs, LDBM *ldbm);
49 static LDAPMod **diff_centroids(char *attr, LDBM oldbm, LDBM nldbm, int nentries);
50 static LDAPMod **full_centroid(char *attr, LDBM ldbm, int nentries);
51 static char **charray_add_dup(char ***a, int *cur, int *max, char *s);
53 static void usage( char *name )
55 fprintf( stderr, "usage: %s [options] -s url -d url attributes\n", name );
56 fprintf( stderr, "where:\n" );
57 fprintf( stderr, "\t-s url\t\t[[ldap://][host[:port]]/]searchbasedn\n");
58 fprintf( stderr, "\t-d url\t\t[[ldap://][host[:port]]/]centroidentrydn\n");
59 fprintf( stderr, "options:\n" );
60 fprintf( stderr, "\t-v \t\tturn on verbose mode\n" );
61 fprintf( stderr, "\t-n \t\tgenerate, but do not install index info\n" );
62 fprintf( stderr, "\t-f filter\tentry selection filter\n" );
63 fprintf( stderr, "\t-F \t\tgenerate a full centroid\n" );
64 fprintf( stderr, "\t-R \t\tgenerate a relative centroid\n" );
65 fprintf( stderr, "\t-w \t\tgenerate a word-based centroid\n" );
66 fprintf( stderr, "\t-t directory\tcentroid directory\n" );
67 fprintf( stderr, "\t-b binddn\tsource bind dn\n" );
68 fprintf( stderr, "\t-p passwd\tsource bind passwd (for simple auth)\n" );
69 fprintf( stderr, "\t-m authmethod\tsource authmethod \"simple\" or \"kerberos\"\n" );
70 fprintf( stderr, "\t-B binddn\tdestination bind dn\n" );
71 fprintf( stderr, "\t-P passwd\tdestination bind passwd (for simple auth)\n" );
72 fprintf( stderr, "\t-M authmethod\tdestination authmethod \"simple\" or \"kerberos\"\n" );
73 fprintf( stderr, "\t-c size\t\tldbm cache size\n" );
77 main( int argc, char **argv )
80 char *ldapsrcurl, *ldapdesturl;
95 srcldapauthmethod = LDAP_AUTH_SIMPLE;
96 destldapauthmethod = LDAP_AUTH_SIMPLE;
99 destldapbinddn = NULL;
100 destldappasswd = NULL;
101 ldapfilter = DEFAULT_LDAPFILTER;
102 centroidvalues = CENTROID_VALUE;
103 centroidtype = CENTROID_RELATIVE;
108 while ( (i = getopt( argc, argv, "s:d:c:b:B:f:FRWp:P:m:M:t:vwn" ))
111 case 's': /* source url [[ldap://][host[:port]]/]basedn */
112 ldapsrcurl = strdup( optarg );
115 case 'd': /* destination url [[ldap://][host[:port]]/]entrydn */
116 ldapdesturl = strdup( optarg );
119 case 'f': /* specify a filter */
120 ldapfilter = strdup( optarg );
123 case 'F': /* generate full centroid */
124 centroidtype = CENTROID_FULL;
127 case 'R': /* generate relative centroid */
128 centroidtype = CENTROID_RELATIVE;
131 case 'w': /* generate word centroid */
132 centroidvalues = CENTROID_WORD;
135 case 'W': /* generate weights */
139 case 't': /* temp file directory */
140 centdir = strdup( optarg );
143 case 'b': /* src bind dn */
144 srcldapbinddn = strdup( optarg );
147 case 'p': /* src bind password */
148 srcldappasswd = strdup( optarg );
153 case 'B': /* dest bind dn */
154 destldapbinddn = strdup( optarg );
157 case 'P': /* dest bind password */
158 destldappasswd = strdup( optarg );
163 case 'm': /* src bind method */
164 if ( strcasecmp( optarg, "simple" ) == 0 ) {
165 srcldapauthmethod = LDAP_AUTH_SIMPLE;
166 } else if ( strcasecmp( optarg, "kerberos" ) == 0 ) {
167 srcldapauthmethod = LDAP_AUTH_KRBV4;
169 fprintf( stderr, "%s: unknown auth method\n", optarg );
170 fputs( "expecting \"simple\" or \"kerberos\"\n", stderr );
175 case 'M': /* dest bind method */
176 if ( strcasecmp( optarg, "simple" ) == 0 ) {
177 destldapauthmethod = LDAP_AUTH_SIMPLE;
178 } else if ( strcasecmp( optarg, "kerberos" ) == 0 ) {
179 destldapauthmethod = LDAP_AUTH_KRBV4;
181 fprintf( stderr, "%s: unknown auth method\n", optarg );
182 fputs( "expecting \"simple\" or \"kerberos\"\n", stderr );
187 case 'c': /* ldbm cache size */
188 ldbmcachesize = atoi( optarg );
191 case 'v': /* turn on verbose mode */
195 case 'n': /* don't actually install index info */
204 if ( optind == argc || ldapsrcurl == NULL || ldapdesturl == NULL ) {
208 attrs = &argv[optind];
211 * open the ldap connection and start searching for the entries
212 * we will use to generate the centroids.
215 if ( (ld = start_ldap_search( ldapsrcurl, ldapfilter, attrs )) == NULL ) {
216 fprintf( stderr, "could not initiate ldap search\n" );
220 if ( create_tmp_files( attrs, &tmpfile, &ldbm ) != 0 ) {
221 fprintf( stderr, "could not create temp files\n" );
226 * go through the entries returned, building a centroid for each
227 * attribute as we go.
230 if ( (count = generate_new_centroids( ld, attrs, ldbm )) < 1 ) {
232 fprintf( stderr, "no entries matched\n" );
235 fprintf( stderr, "could not generate new centroid\n" );
241 * for each centroid we generated above, compare to the existing
242 * centroid, if any, and produce adds and deletes, or produce
243 * an entirely new centroid. in either case, update the "current"
244 * centroid version with the new one we just generated.
247 if ( (ld = bind_to_destination_ldap( ldapsrcurl, ldapdesturl )) == NULL ) {
249 "could not bind to index server, or could not create index entry\n" );
253 for ( i = 0; ldbm[i] != NULL; i++ ) {
254 /* generate the name of the existing centroid, if any */
255 s = strrchr( tmpfile[i], '/' );
257 sprintf( buf, "%s/cent.%s", tmpfile[i], attrs[i] );
260 /* generate the full centroid changes */
261 if ( centroidtype == CENTROID_FULL || (oldbm = ldbm_open( buf,
262 LDBM_WRITER, 0, ldbmcachesize )) == NULL ) {
263 if ( (mods = full_centroid( attrs[i], ldbm[i], count )) == NULL ) {
264 fprintf( stderr, "could not produce full centroid for %s\n",
269 /* generate the differential centroid changes */
271 if ( (mods = diff_centroids( attrs[i], oldbm, ldbm[i], count ))
273 fprintf( stderr, "could not diff centroids\n" );
281 printf("changes:\n");
282 for ( j = 0; mods[j] != NULL; j++ ) {
283 switch( mods[j]->mod_op ) {
285 printf( "\tadd: %s\n",mods[j]->mod_type );
287 case LDAP_MOD_DELETE:
288 printf( "\tdelete: %s\n",mods[j]->mod_type );
290 case LDAP_MOD_REPLACE:
291 printf( "\treplace: %s\n",mods[j]->mod_type );
294 if ( mods[j]->mod_values != NULL ) {
295 for ( k = 0; mods[j]->mod_values[k] != NULL; k++ ) {
296 printf( "\t\t%s\n", mods[j]->mod_values[k] );
300 printf("end changes:\n");
304 printf( "%sModifying centroid...", not ? "Not " : "" );
308 /* attempt to make the changes to the index server entry */
309 if ( !not && ldap_modify_s( ld, ldapbase, mods ) != LDAP_SUCCESS ) {
310 fprintf( stderr, "could not apply centroid modification for %s\n",
312 ldap_perror( ld, ldapbase );
314 ldap_mods_free( mods, 1 );
321 /* move the new centroid into the old one's place */
323 (void) unlink( buf );
324 if ( link( tmpfile[i], buf ) != 0 ) {
326 fprintf( stderr, "could not rename %s to %s\n", buf,
331 (void) unlink( tmpfile[i] );
335 for ( i = 0; attrs[i] != NULL; i++ ) {
336 ldbm_close( ldbm[i] );
346 * open an ldap connection, bind, and initiate the search
360 if ( strncmp( ldapsrcurl, "ldap://", 7 ) != 0 ) {
361 fputs( "Not an LDAP URL", stderr ); /* Should be smarter? */
365 if ( (s2 = strchr( s, '/' )) == NULL ) {
366 ldapbase = strdup( s );
370 ldaphost = strdup( s );
373 ldapbase = strdup( s2 + 1 );
377 printf( "Base: %s\n", ldapbase );
378 printf( "Attributes:" );
379 for ( i = 0; attrs[i] != NULL; i++ ) {
380 printf( " %s", attrs[i] );
383 printf( "Binding to source LDAP server..." );
387 if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
388 perror( "ldap_open" );
392 if ( ldap_bind_s( ld, srcldapbinddn, srcldappasswd, srcldapauthmethod )
394 ldap_perror( ld, "ldap_bind_s" );
399 printf( "\nInitiating search..." );
400 if ( ldap_search( ld, ldapbase, LDAP_SCOPE_SUBTREE, ldapfilter, attrs, 0 )
402 ldap_perror( ld, "ldap_search" );
415 * create the temporary ldbm files we will use to hold the new centroids
427 for ( i = 0; attrs[i] != NULL; i++ )
431 if ( (*tmpfile = (char **) malloc( i * sizeof(char *) )) == NULL ) {
435 if ( (*ldbm = (LDBM *) malloc( i * sizeof(LDBM) )) == NULL ) {
439 for ( i = 0; attrs[i] != NULL; i++ ) {
440 if ( ((*tmpfile)[i] = tempnam( centdir, NULL )) == NULL ) {
445 if ( ((*ldbm)[i] = ldbm_open( (*tmpfile)[i], LDBM_WRCREAT, 0600,
446 ldbmcachesize )) == NULL ) {
447 fprintf( stderr, "ldbm_open of \"%s\" failed\n", (*tmpfile)[i] );
448 perror( "ldbm_open" );
452 (*tmpfile)[i] = NULL;
459 * step through each entry returned from the search and generate
460 * the appropriate centroid values.
464 generate_new_centroids(
472 LDAPMessage *res, *e;
477 ldbm_datum_init( data );
480 printf( "Generating new centroids for..." );
487 while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res ))
488 == LDAP_RES_SEARCH_ENTRY ) {
490 e = ldap_first_entry( ld, res );
491 dn = ldap_get_dn( ld, e );
493 /* for each attr we want to generate a centroid for */
494 for ( i = 0; attrs[i] != NULL; i++ ) {
495 if ( (val = ldap_get_values( ld, e, attrs[i] )) == NULL ) {
500 for ( j = 0; val[j] != NULL; j++ ) {
502 ldbm_datum_init( key );
504 /* normalize the value */
505 for ( s = val[j]; *s; s++ ) {
506 if ( isascii( *s ) ) {
511 if ( isascii( last ) && isdigit( last ) ) {
515 /* generate a value-based centroid */
516 if ( centroidvalues == CENTROID_VALUE ) {
518 key.dsize = strlen( key.dptr ) + 1;
519 (void) ldbm_store( ldbm[i], key, data, LDBM_INSERT );
521 /* generate a word-based centroid */
523 for ( w = strtok( val[j], WORD_BREAKS ); w != NULL;
524 w = strtok( NULL, WORD_BREAKS ) ) {
526 key.dsize = strlen( key.dptr ) + 1;
527 (void) ldbm_store( ldbm[i], key, data, LDBM_INSERT );
531 ldap_value_free( val );
540 printf( "%d entries\n", count );
547 * compare the old and new centroids, generating the appropriate add
548 * and delete operations. if the underlying database is ordered, we
549 * can do this more efficiently.
565 char **avals, **dvals;
566 int amax, acur, dmax, dcur;
569 #ifdef HAVE_BERKELEY_DB2
572 #endif /* HAVE_BERKELEY_DB2 */
575 printf( "Generating mods for differential %s centroid...", attr );
579 ldbm_datum_init( okey );
580 ldbm_datum_init( nkey );
581 ldbm_datum_init( olast );
582 ldbm_datum_init( nlast );
583 ldbm_datum_init( lastkey );
584 ldbm_datum_init( key );
585 ldbm_datum_init( data );
587 if ( (mods = (LDAPMod **) malloc( sizeof(LDAPMod *) * 4 )) == NULL ||
588 (mods[0] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
589 (mods[1] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
590 (mods[2] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
591 (vals = (char **) malloc( 2 * sizeof(char *) )) == NULL ||
592 (vals[0] = (char *) malloc( 20 )) == NULL )
597 /* add values in mods[0] */
598 mods[0]->mod_op = LDAP_MOD_ADD;
599 mods[0]->mod_type = attr;
600 mods[0]->mod_values = NULL;
603 /* delete values in mods[1] */
604 mods[1]->mod_op = LDAP_MOD_DELETE;
605 mods[1]->mod_type = attr;
606 mods[1]->mod_values = NULL;
609 /* number of entries in mods[2] */
610 sprintf( vals[0], "%d", nentries );
612 mods[2]->mod_op = LDAP_MOD_REPLACE;
613 mods[2]->mod_type = "nentries";
614 mods[2]->mod_values = vals;
615 /* null terminate list of mods */
620 * if the underlying database is ordered, we can do a more efficient
621 * dual traversal, yielding O(N) performance.
626 #ifdef HAVE_BERKELEY_DB2
627 for ( okey = ldbm_firstkey( oldbm, &ocursorp ),
628 nkey = ldbm_firstkey( nldbm, &ncursorp );
629 okey.dptr != NULL && nkey.dptr != NULL; )
631 for ( okey = ldbm_firstkey( oldbm ), nkey = ldbm_firstkey( nldbm );
632 okey.dptr != NULL && nkey.dptr != NULL; )
635 int rc = strcmp( okey.dptr, nkey.dptr );
638 /* value is in both places - leave it */
639 if ( olast.dptr != NULL ) {
640 ldbm_datum_free( oldbm, olast );
643 if ( nlast.dptr != NULL ) {
644 ldbm_datum_free( nldbm, nlast );
648 #ifdef HAVE_BERKELEY_DB2
649 okey = ldbm_nextkey( oldbm, olast, ocursorp );
650 nkey = ldbm_nextkey( nldbm, nlast, ncursorp );
652 okey = ldbm_nextkey( oldbm, olast );
653 nkey = ldbm_nextkey( nldbm, nlast );
655 } else if ( rc > 0 ) {
656 /* new value is not in old centroid - add it */
657 if ( charray_add_dup( &avals, &acur, &amax, nkey.dptr ) == NULL ) {
658 ldap_mods_free( mods, 1 );
662 if ( nlast.dptr != NULL ) {
663 ldbm_datum_free( nldbm, nlast );
667 #ifdef HAVE_BERKELEY_DB2
668 nkey = ldbm_nextkey( nldbm, nlast, ncursorp );
670 nkey = ldbm_nextkey( nldbm, nlast );
673 /* old value is not in new centroid - delete it */
674 if ( charray_add_dup( &dvals, &dcur, &dmax, okey.dptr ) == NULL ) {
675 ldap_mods_free( mods, 1 );
679 if ( olast.dptr != NULL ) {
680 ldbm_datum_free( oldbm, olast );
684 #ifdef HAVE_BERKELEY_DB2
685 okey = ldbm_nextkey( oldbm, olast, ocursorp );
687 okey = ldbm_nextkey( oldbm, olast );
692 while ( okey.dptr != NULL ) {
693 if ( charray_add_dup( &dvals, &dcur, &dmax, okey.dptr ) == NULL ) {
694 ldap_mods_free( mods, 1 );
698 #ifdef HAVE_BERKELEY_DB2
699 okey = ldbm_nextkey( oldbm, olast, ocursorp );
701 okey = ldbm_nextkey( oldbm, olast );
703 if ( olast.dptr != NULL ) {
704 ldbm_datum_free( oldbm, olast );
708 if ( olast.dptr != NULL ) {
709 ldbm_datum_free( oldbm, olast );
711 while ( nkey.dptr != NULL ) {
712 if ( charray_add_dup( &avals, &acur, &amax, nkey.dptr ) == NULL ) {
713 ldap_mods_free( mods, 1 );
717 #ifdef HAVE_BERKELEY_DB2
718 nkey = ldbm_nextkey( nldbm, nlast, ncursorp );
720 nkey = ldbm_nextkey( nldbm, nlast );
722 if ( nlast.dptr != NULL ) {
723 ldbm_datum_free( nldbm, nlast );
727 if ( nlast.dptr != NULL ) {
728 ldbm_datum_free( nldbm, nlast );
732 * if the underlying database is not ordered, we have to
733 * generate list of values to add by stepping through all new
734 * values and looking them up in the old centroid (not there => add),
735 * then stepping through all old values and looking them up in the
736 * new centroid (not there => delete). this yields O(Nf(N)) performance,
737 * where f(N) is the order to retrieve a single item.
740 /* generate list of values to add */
742 #ifdef HAVE_BERKELEY_DB2
743 for ( key = ldbm_firstkey( nldbm, &ncursorp ); key.dptr != NULL;
744 key = ldbm_nextkey( nldbm, lastkey, ncursorp ) )
746 for ( key = ldbm_firstkey( nldbm ); key.dptr != NULL;
747 key = ldbm_nextkey( nldbm, lastkey ) )
750 /* see if it's in the old one */
751 data = ldbm_fetch( oldbm, key );
753 /* not there - add it */
754 if ( data.dptr == NULL ) {
755 if ( charray_add_dup( &avals, &acur, &amax, key.dptr ) == NULL ) {
756 ldap_mods_free( mods, 1 );
760 ldbm_datum_free( oldbm, data );
762 if ( lastkey.dptr != NULL ) {
763 ldbm_datum_free( nldbm, lastkey );
767 if ( lastkey.dptr != NULL ) {
768 ldbm_datum_free( nldbm, lastkey );
771 /* generate list of values to delete */
773 #ifdef HAVE_BERKELEY_DB2
774 for ( key = ldbm_firstkey( oldbm, &ocursorp ); key.dptr != NULL;
775 key = ldbm_nextkey( oldbm, lastkey, ocursorp ) )
777 for ( key = ldbm_firstkey( oldbm ); key.dptr != NULL;
778 key = ldbm_nextkey( oldbm, lastkey ) )
781 /* see if it's in the new one */
782 data = ldbm_fetch( nldbm, key );
784 /* not there - delete it */
785 if ( data.dptr == NULL ) {
786 if ( charray_add_dup( &dvals, &dcur, &dmax, key.dptr ) == NULL ) {
787 ldap_mods_free( mods, 1 );
791 ldbm_datum_free( nldbm, data );
793 if ( lastkey.dptr != NULL ) {
794 ldbm_datum_free( oldbm, lastkey );
798 if ( lastkey.dptr != NULL ) {
799 ldbm_datum_free( oldbm, lastkey );
803 mods[0]->mod_values = avals;
804 mods[1]->mod_values = dvals;
811 if ( mods[1]->mod_values == NULL ) {
812 free( (char *) mods[1] );
815 if ( mods[0]->mod_values == NULL ) {
816 free( (char *) mods[0] );
820 if ( mods[0] == NULL ) {
821 free( (char *) mods );
840 #ifdef HAVE_BERKELEY_DB2
845 printf( "Generating mods for full %s centroid...", attr );
849 ldbm_datum_init( key );
850 ldbm_datum_init( lastkey );
852 if ( (mods = (LDAPMod **) malloc( sizeof(LDAPMod *) * 3 )) == NULL ||
853 (mods[0] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
854 (mods[1] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
855 (vals = (char **) malloc( 2 * sizeof(char *) )) == NULL ||
856 (vals[0] = (char *) malloc( 20 )) == NULL )
861 mods[0]->mod_op = LDAP_MOD_REPLACE;
862 mods[0]->mod_type = attr;
863 mods[0]->mod_values = NULL;
864 sprintf( vals[0], "%d", nentries );
866 mods[1]->mod_op = LDAP_MOD_REPLACE;
867 mods[1]->mod_type = "nentries";
868 mods[1]->mod_values = vals;
874 #ifdef HAVE_BERKELEY_DB2
875 for ( key = ldbm_firstkey( ldbm, &cursorp ); key.dptr != NULL;
876 key = ldbm_nextkey( ldbm, lastkey, cursorp ) )
878 for ( key = ldbm_firstkey( ldbm ); key.dptr != NULL;
879 key = ldbm_nextkey( ldbm, lastkey ) )
882 if ( charray_add_dup( &vals, &vcur, &vmax, key.dptr ) == NULL ) {
883 ldap_mods_free( mods, 1 );
887 if ( lastkey.dptr != NULL ) {
888 ldbm_datum_free( ldbm, lastkey );
892 if ( lastkey.dptr != NULL ) {
893 ldbm_datum_free( ldbm, lastkey );
895 mods[0]->mod_values = vals;
902 if ( mods[0]->mod_values == NULL ) {
903 free( (char *) mods[0] );
904 free( (char *) mods );
912 * extract the destination ldap host, port, and base object for the
913 * server to receive the index information. then, open a connection,
914 * bind, and see if the entry exists. if not, create it and set things
915 * up so the centroid full and diff routines can modify it to contain
916 * the new centroid information.
920 bind_to_destination_ldap(
929 char *attrs[2], *refvalues[2], *ocvalues[2];
935 printf( "Binding to destination LDAP server..." );
939 /* first, pick out the destination ldap server info */
940 if ( ldapbase != NULL ) {
944 if ( strncmp( ldapdesturl, "ldap://", 7 ) != 0 ) {
945 fputs( "Not an LDAP URL", stderr ); /* Should be smarter? */
949 if ( (s2 = strchr( s, '/' )) == NULL ) {
950 ldapbase = strdup( s );
954 if ( ldaphost != NULL )
956 ldaphost = strdup( s );
959 ldapbase = strdup( s2 + 1 );
961 strcpy( buf, "ref=" );
962 if ( strpbrk( ldapsrcurl, " ,;" ) != NULL ) {
965 for ( s = d = ldapsrcurl; *s; s++ ) {
971 strcat( buf, ldapsrcurl );
972 if ( strpbrk( ldapsrcurl, " ,;" ) != NULL ) {
976 strcat( buf, ldapbase );
978 ldapbase = strdup( buf );
980 if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
981 perror( "ldap_open" );
985 if ( ldap_bind_s( ld, destldapbinddn, destldappasswd, destldapauthmethod )
987 ldap_perror( ld, "ldap_bind_s" );
997 rc = ldap_search_s( ld, ldapbase, LDAP_SCOPE_BASE, "(objectclass=*)",
1001 if ( rc == LDAP_NO_SUCH_OBJECT ) {
1003 printf( "%sCreating centroid entry...", not ? "Not " : "" );
1007 /* create the centroid index entry */
1009 m[0].mod_type = "ref";
1010 refvalues[0] = ldapsrcurl;
1011 refvalues[1] = NULL;
1012 m[0].mod_values = refvalues;
1014 m[1].mod_type = "objectclass";
1015 ocvalues[0] = "indexentry";
1017 m[1].mod_values = ocvalues;
1022 if ( !not && ldap_add_s( ld, ldapbase, mp ) != LDAP_SUCCESS ) {
1023 ldap_perror( ld, ldapbase );
1032 } else if ( rc != LDAP_SUCCESS ) {
1033 ldap_perror( ld, "ldap_search_s" );
1052 *a = (char **) malloc( (BUFSIZ + 1) * sizeof(char *) );
1055 } else if ( *cur >= *max ) {
1057 *a = (char **) realloc( *a, (*max + 1) * sizeof(char *) );
1063 (*a)[(*cur)++] = strdup( s );