2 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * (C) Copyright IBM Corp. 1997,2002
7 * Redistribution and use in source and binary forms are permitted
8 * provided that this notice is preserved and that due credit is
9 * given to IBM Corporation. This software is provided ``as is''
10 * without express or implied warranty.
14 #include "slapi_common.h"
24 struct berval *ns_get_supported_extop( int );
27 #include <sys/systeminfo.h>
33 * server start time (should we use a struct timeval also in slapd?
35 static struct timeval base_time;
36 ldap_pvt_thread_mutex_t slapi_hn_mutex;
37 ldap_pvt_thread_mutex_t slapi_time_mutex;
40 * This function converts an array of pointers to berval objects to
41 * an array of berval objects.
46 struct berval **bvptr,
49 int rc = LDAP_SUCCESS;
53 if ( bvptr == NULL || *bvptr == NULL ) {
57 for ( i = 0; bvptr != NULL && bvptr[i] != NULL; i++ ) {
61 tmpberval = (BerVarray)slapi_ch_malloc( (i + 1)*sizeof(struct berval));
62 if ( tmpberval == NULL ) {
63 return LDAP_NO_MEMORY;
66 for ( i = 0; bvptr[i] != NULL; i++ ) {
67 tmpberval[i].bv_val = bvptr[i]->bv_val;
68 tmpberval[i].bv_len = bvptr[i]->bv_len;
71 if ( rc == LDAP_SUCCESS ) {
83 #if defined(LDAP_SLAPI)
84 Slapi_Entry *e = NULL;
87 pTmpS = slapi_ch_strdup( s );
88 if ( pTmpS != NULL ) {
89 e = str2entry( pTmpS );
90 slapi_ch_free( pTmpS );
94 #else /* !defined(LDAP_SLAPI) */
96 #endif /* !defined(LDAP_SLAPI) */
104 #if defined(LDAP_SLAPI)
107 ldap_pvt_thread_mutex_lock( &entry2str_mutex );
108 ret = entry2str( e, len );
109 ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
112 #else /* !defined(LDAP_SLAPI) */
114 #endif /* !defined(LDAP_SLAPI) */
118 slapi_entry_get_dn( Slapi_Entry *e )
120 #if defined(LDAP_SLAPI)
121 return e->e_name.bv_val;
122 #else /* !defined(LDAP_SLAPI) */
124 #endif /* !defined(LDAP_SLAPI) */
132 #if defined(LDAP_SLAPI)
133 struct berval dn = { 0, NULL };
136 dn.bv_len = strlen( ldn );
138 dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname );
139 #endif /* defined(LDAP_SLAPI) */
143 slapi_entry_dup( Slapi_Entry *e )
145 #if defined(LDAP_SLAPI)
150 tmp = slapi_entry2str( e, &len );
152 return (Slapi_Entry *)NULL;
155 tmpEnt = (Slapi_Entry *)str2entry( tmp );
156 if ( tmpEnt == NULL ) {
157 slapi_ch_free( tmp );
158 return (Slapi_Entry *)NULL;
162 slapi_ch_free( tmp );
166 #else /* !defined(LDAP_SLAPI) */
168 #endif /* !defined(LDAP_SLAPI) */
172 slapi_entry_attr_delete(
176 #if defined(LDAP_SLAPI)
177 AttributeDescription *ad;
180 if ( slap_str2ad( type, &ad, &text ) != LDAP_SUCCESS ) {
181 return 1; /* LDAP_NO_SUCH_ATTRIBUTE */
184 if ( attr_delete( &e->e_attrs, ad ) == LDAP_SUCCESS ) {
185 return 0; /* attribute is deleted */
187 return -1; /* something went wrong */
189 #else /* !defined(LDAP_SLAPI) */
191 #endif /* !defined(LDAP_SLAPI) */
195 slapi_entry_alloc( void )
197 #if defined(LDAP_SLAPI)
198 return (Slapi_Entry *)slapi_ch_calloc( 1, sizeof(Slapi_Entry) );
199 #else /* !defined(LDAP_SLAPI) */
201 #endif /* !defined(LDAP_SLAPI) */
205 slapi_entry_free( Slapi_Entry *e )
207 #if defined(LDAP_SLAPI)
209 #endif /* defined(LDAP_SLAPI) */
213 slapi_entry_attr_merge(
216 struct berval **vals )
218 #if defined(LDAP_SLAPI)
219 AttributeDescription *ad;
224 rc = bvptr2obj( vals, &bv );
225 if ( rc != LDAP_SUCCESS ) {
229 rc = slap_str2ad( type, &ad, &text );
230 if ( rc != LDAP_SUCCESS ) {
234 rc = attr_merge( e, ad, bv );
238 #else /* !defined(LDAP_SLAPI) */
240 #endif /* !defined(LDAP_SLAPI) */
244 slapi_entry_attr_find(
249 #if defined(LDAP_SLAPI)
250 AttributeDescription *ad;
254 rc = slap_str2ad( type, &ad, &text );
255 if ( rc != LDAP_SUCCESS ) {
259 *attr = attr_find( e->e_attrs, ad );
260 if ( *attr == NULL ) {
265 #else /* !defined(LDAP_SLAPI) */
267 #endif /* !defined(LDAP_SLAPI) */
271 * FIXME -- The caller must free the allocated memory.
272 * In Netscape they do not have to.
275 slapi_attr_get_values(
277 struct berval ***vals )
279 #if defined(LDAP_SLAPI)
283 if ( attr == NULL ) {
287 for ( i = 0; attr->a_vals[i].bv_val != NULL; i++ ) {
291 bv = (struct berval **)ch_malloc( (i + 1) * sizeof(struct berval *) );
292 for ( j = 0; j < i; j++ ) {
293 bv[j] = (struct berval *)ch_malloc( sizeof(struct berval) );
294 bv[j]->bv_val = ch_strdup( attr->a_vals[j].bv_val );
295 bv[j]->bv_len = attr->a_vals[j].bv_len;
299 *vals = (struct berval **)bv;
302 #else /* !defined(LDAP_SLAPI) */
304 #endif /* !defined(LDAP_SLAPI) */
308 slapi_dn_normalize( char *dn )
310 #if defined(LDAP_SLAPI)
314 assert( dn != NULL );
317 bdn.bv_len = strlen( dn );
319 dnNormalize2( NULL, &bdn, &ndn );
322 * FIXME: ain't it safe to set dn = ndn.bv_val ?
324 dn = ch_strdup( ndn.bv_val );
325 ch_free( ndn.bv_val );
328 #else /* !defined(LDAP_SLAPI) */
330 #endif /* !defined(LDAP_SLAPI) */
334 * FIXME: this function is dangerous and should be deprecated;
335 * DN normalization is a lot more than lower-casing, and BTW
336 * OpenLDAP's DN normalization for case insensitive attributes
337 * is already lower case
340 slapi_dn_normalize_case( char *dn )
342 #if defined(LDAP_SLAPI)
343 slapi_dn_normalize( dn );
344 ldap_pvt_str2lower( dn );
347 #else /* defined(LDAP_SLAPI) */
349 #endif /* defined(LDAP_SLAPI) */
357 #if defined(LDAP_SLAPI)
358 struct berval bdn, ndn;
359 struct berval bsuffix, nsuffix;
361 assert( dn != NULL );
362 assert( suffix != NULL );
365 bdn.bv_len = strlen( dn );
367 bsuffix.bv_val = suffix;
368 bsuffix.bv_len = strlen( suffix );
370 dnNormalize2( NULL, &bdn, &ndn );
371 dnNormalize2( NULL, &bsuffix, &nsuffix );
373 return dnIsSuffix( &ndn, &nsuffix );
374 #else /* !defined(LDAP_SLAPI) */
376 #endif /* !defined(LDAP_SLAPI) */
380 slapi_dn_ignore_case( char *dn )
382 #if defined(LDAP_SLAPI)
383 return slapi_dn_normalize_case( dn );
384 #else /* !defined(LDAP_SLAPI) */
386 #endif /* !defined(LDAP_SLAPI) */
390 slapi_ch_malloc( unsigned long size )
392 #if defined(LDAP_SLAPI)
393 return ch_malloc( size );
394 #else /* !defined(LDAP_SLAPI) */
396 #endif /* !defined(LDAP_SLAPI) */
400 slapi_ch_free( void *ptr )
402 #if defined(LDAP_SLAPI)
404 if ( ptr != NULL ) /* not required ... */
407 #endif /* defined(LDAP_SLAPI) */
415 #if defined(LDAP_SLAPI)
416 return ch_calloc( nelem, size );
417 #else /* !defined(LDAP_SLAPI) */
419 #endif /* !defined(LDAP_SLAPI) */
427 #if defined(LDAP_SLAPI)
428 return ch_realloc( block, size );
429 #else /* !defined(LDAP_SLAPI) */
431 #endif /* !defined(LDAP_SLAPI) */
435 slapi_ch_strdup( char *s )
437 #if defined(LDAP_SLAPI)
438 return ch_strdup( (const char *)s );
439 #else /* !defined(LDAP_SLAPI) */
441 #endif /* !defined(LDAP_SLAPI) */
445 slapi_ch_stlen( char *s )
447 #if defined(LDAP_SLAPI)
448 return strlen( (const char *)s );
449 #else /* !defined(LDAP_SLAPI) */
451 #endif /* !defined(LDAP_SLAPI) */
455 slapi_control_present(
456 LDAPControl **controls,
461 #if defined(LDAP_SLAPI)
473 for ( i = 0; controls != NULL && controls[i] != NULL; i++ ) {
474 if ( strcmp( controls[i]->ldctl_oid, oid ) != 0 ) {
479 if ( controls[i]->ldctl_value.bv_len != 0 ) {
481 * FIXME: according to 6.1 specification,
482 * "The val output parameter is set
483 * to point into the controls array.
484 * A copy of the control value is
488 struct berval *pTmpBval;
490 pTmpBval = (struct berval *)slapi_ch_malloc( sizeof(struct berval));
491 if ( pTmpBval == NULL ) {
494 pTmpBval->bv_len = controls[i]->ldctl_value.bv_len;
495 pTmpBval->bv_val = controls[i]->ldctl_value.bv_val;
499 slapi_ch_free( pTmpBval );
505 *val = &controls[i]->ldctl_value;
510 *iscritical = controls[i]->ldctl_iscritical;
517 #else /* !defined(LDAP_SLAPI) */
519 #endif /* !defined(LDAP_SLAPI) */
523 slapi_register_supported_control(
525 unsigned long controlops )
527 #if defined(LDAP_SLAPI)
528 /* FIXME -- can not add controls to openLDAP dynamically */
529 slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_CONTROLS",
530 "can not add controls to openLDAP dynamically\n" );
531 #endif /* defined(LDAP_SLAPI) */
535 slapi_get_supported_controls(
537 unsigned long **ctrlopsp )
539 #if defined(LDAP_SLAPI)
543 unsigned long *masks = NULL;
545 for (n = 0; get_supported_ctrl( n ) != NULL; n++) {
557 oids = (char **)slapi_ch_malloc( (n + 1) * sizeof(char *) );
558 if ( oids == NULL ) {
563 masks = (unsigned long *)slapi_ch_malloc( n * sizeof(int) );
564 if ( masks == NULL ) {
569 for ( i = 0; i < n; i++ ) {
571 * FIXME: Netscape's specification says nothing about
572 * memory; should we copy the OIDs or return pointers
573 * to internal values? In OpenLDAP the latter is safe
574 * since we do not allow to register coltrols runtime
576 oids[ i ] = ch_strdup( get_supported_ctrl( i ) );
577 if ( oids[ i ] == NULL ) {
581 masks[ i ] = (unsigned long)get_supported_ctrl_mask( i );
589 if ( rc != LDAP_SUCCESS ) {
590 for ( i = 0; oids != NULL && oids[ i ] != NULL; i++ ) {
591 ch_free( oids[ i ] );
598 #else /* !defined(LDAP_SLAPI) */
600 #endif /* !defined(LDAP_SLAPI) */
604 slapi_register_supported_saslmechanism( char *mechanism )
606 #if defined(LDAP_SLAPI)
607 /* FIXME -- can not add saslmechanism to openLDAP dynamically */
608 slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SASL",
609 "can not add saslmechanism to openLDAP dynamically\n" );
610 #endif /* defined(LDAP_SLAPI) */
614 slapi_get_supported_saslmechanisms( void )
616 #if defined(LDAP_SLAPI)
617 /* FIXME -- can not get the saslmechanism wihtout a connection. */
618 slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SASL",
619 "can not get the saslmechanism "
620 "wihtout a connection\n" );
622 #else /* defined(LDAP_SLAPI) */
624 #endif /* defined(LDAP_SLAPI) */
628 slapi_get_supported_extended_ops( void )
630 #if defined(LDAP_SLAPI)
632 char **ppExtOpOID = NULL;
635 for ( i = 0; get_supported_extop( i ) != NULL; i++ ) {
639 for ( j = 0; ns_get_supported_extop( j ) != NULL; j++ ) {
644 if ( numExtOps == 0 ) {
648 ppExtOpOID = (char **)slapi_ch_malloc( (numExtOps + 1) * sizeof(char *) );
649 for ( k = 0; k < i; k++ ) {
652 bv = get_supported_extop( k );
653 assert( bv != NULL );
655 ppExtOpOID[ k ] = bv->bv_val;
658 for ( ; k < j; k++ ) {
661 bv = ns_get_supported_extop( k );
662 assert( bv != NULL );
664 ppExtOpOID[ i + k ] = bv->bv_val;
666 ppExtOpOID[ i + k ] = NULL;
669 #else /* !defined(LDAP_SLAPI) */
671 #endif /* !defined(LDAP_SLAPI) */
675 slapi_send_ldap_result(
681 struct berval **urls )
683 #if defined(LDAP_SLAPI)
688 struct berval *extValue = NULL;
691 slapi_pblock_get( pb, SLAPI_CONNECTION, &conn );
692 slapi_pblock_get( pb, SLAPI_OPERATION, &op );
693 if ( err == LDAP_SASL_BIND_IN_PROGRESS ) {
694 slapi_pblock_get( pb, SLAPI_BIND_RET_SASLCREDS, &s );
695 rc = LDAP_SASL_BIND_IN_PROGRESS;
696 send_ldap_sasl( conn, op, rc, NULL, NULL, NULL, NULL, s );
700 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, &extOID );
701 if ( extOID != NULL ) {
702 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, &extValue );
703 slapi_send_ldap_extended_response( conn, op, err, extOID,
708 send_ldap_result( conn, op, err, matched, text, NULL, NULL );
709 #endif /* defined(LDAP_SLAPI) */
713 slapi_send_ldap_search_entry(
716 LDAPControl **ectrls,
720 #if defined(LDAP_SLAPI)
727 AttributeName *an = NULL;
730 for ( i = 0; attrs[ i ] != NULL; i++ ) {
735 an = (AttributeName *) ch_malloc( i * sizeof(AttributeName) );
736 for ( i = 0; attrs[i] != NULL; i++ ) {
737 an[i].an_name.bv_val = ch_strdup( attrs[i] );
738 an[i].an_name.bv_len = strlen( attrs[i] );
739 an[i].an_desc = NULL;
740 if( slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text ) != LDAP_SUCCESS)
745 if ( ( rc = slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&be ) != 0 ) ||
746 ( rc = slapi_pblock_get( pb, SLAPI_CONNECTION, (void *)&pConn) != 0 ) ||
747 ( rc = slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp) != 0 ) ) {
750 rc = send_search_entry( be, pConn, pOp, e, an, attrsonly, NULL );
755 #else /* !defined(LDAP_SLAPI) */
757 #endif /* !defined(LDAP_SLAPI) */
762 slapi_str2filter( char *str )
764 #if defined(LDAP_SLAPI)
765 return str2filter( str );
766 #else /* !defined(LDAP_SLAPI) */
768 #endif /* !defined(LDAP_SLAPI) */
776 #if defined(LDAP_SLAPI)
778 #endif /* defined(LDAP_SLAPI) */
782 slapi_filter_get_choice( Slapi_Filter *f )
784 #if defined(LDAP_SLAPI)
794 #else /* !defined(LDAP_SLAPI) */
795 return -1; /* invalid filter type */
796 #endif /* !defined(LDAP_SLAPI) */
800 slapi_filter_get_ava(
803 struct berval **bval )
805 #if defined(LDAP_SLAPI)
807 int rc = LDAP_SUCCESS;
809 assert( type != NULL );
810 assert( bval != NULL );
816 if ( ftype == LDAP_FILTER_EQUALITY
817 || ftype == LDAP_FILTER_GE
818 || ftype == LDAP_FILTER_LE
819 || ftype == LDAP_FILTER_APPROX ) {
820 *type = slapi_ch_strdup( f->f_un.f_un_ava->aa_desc->ad_cname.bv_val );
821 if ( *type == NULL ) {
826 *bval = (struct berval *)slapi_ch_malloc( sizeof(struct berval) );
827 if ( *bval == NULL ) {
832 (*bval)->bv_len = f->f_un.f_un_ava->aa_value.bv_len;
833 (*bval)->bv_val = slapi_ch_strdup( f->f_un.f_un_ava->aa_value.bv_val );
834 if ( (*bval)->bv_val == NULL ) {
838 } else { /* filter type not supported */
843 if ( rc != LDAP_SUCCESS ) {
856 #else /* !defined(LDAP_SLAPI) */
858 #endif /* !defined(LDAP_SLAPI) */
862 slapi_filter_list_first( Slapi_Filter *f )
864 #if defined(LDAP_SLAPI)
872 if ( ftype == LDAP_FILTER_AND
873 || ftype == LDAP_FILTER_OR
874 || ftype == LDAP_FILTER_NOT ) {
875 return (Slapi_Filter *)f->f_and;
879 #else /* !defined(LDAP_SLAPI) */
881 #endif /* !defined(LDAP_SLAPI) */
885 slapi_filter_list_next(
887 Slapi_Filter *fprev )
889 #if defined(LDAP_SLAPI)
897 if ( ftype == LDAP_FILTER_AND
898 || ftype == LDAP_FILTER_OR
899 || ftype == LDAP_FILTER_NOT ) {
900 if ( f->f_and == fprev ) {
901 return f->f_and->f_next;
906 #else /* !defined(LDAP_SLAPI) */
908 #endif /* !defined(LDAP_SLAPI) */
912 slapi_send_ldap_extended_response(
917 struct berval *response )
919 #if defined(LDAP_SLAPI)
920 send_ldap_extended( conn,op, errornum, NULL, NULL, NULL,
921 respName,response, NULL );
923 #else /* !defined(LDAP_SLAPI) */
925 #endif /* !defined(LDAP_SLAPI) */
930 struct berval **vals,
933 #if defined(LDAP_SLAPI)
935 * FIXME: what's the point?
938 #else /* !defined(LDAP_SLAPI) */
940 #endif /* !defined(LDAP_SLAPI) */
944 slapi_get_hostname( void )
946 #if defined(LDAP_SLAPI)
950 * FIXME: I'd prefer a different check ...
953 hn = (char *)slapi_ch_malloc( MAX_HOSTNAME );
955 slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
956 "can't malloc memory for hostname\n" );
959 } else if ( sysinfo( SI_HOSTNAME, hn, MAX_HOSTNAME ) < 0 ) {
960 slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
961 "can't get hostname\n" );
966 static int been_here = 0;
967 static char *static_hn = NULL;
969 ldap_pvt_thread_mutex_lock( &slapi_hn_mutex );
971 static_hn = (char *)slapi_ch_malloc( MAX_HOSTNAME );
972 if ( static_hn == NULL) {
973 slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
974 "can't malloc memory for hostname\n" );
976 ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex );
981 if ( gethostname( static_hn, MAX_HOSTNAME ) != 0 ) {
982 slapi_log_error( SLAPI_LOG_FATAL,
984 "can't get hostname\n" );
985 slapi_ch_free( static_hn );
987 ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex );
996 ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex );
998 hn = ch_strdup( static_hn );
1002 #else /* !defined(LDAP_SLAPI) */
1004 #endif /* !defined(LDAP_SLAPI) */
1008 * FIXME: this should go in an appropriate header ...
1010 extern int vLogError( int level, char *subsystem, char *fmt, va_list arglist );
1019 #if defined(LDAP_SLAPI)
1020 int rc = LDAP_SUCCESS;
1023 va_start( arglist, fmt );
1024 rc = vLogError( severity, subsystem, fmt, arglist );
1028 #else /* !defined(LDAP_SLAPI) */
1030 #endif /* !defined(LDAP_SLAPI) */
1035 slapi_timer_current_time( void )
1037 #if defined(LDAP_SLAPI)
1038 static int first_time = 1;
1039 #if !defined (_WIN32)
1043 ldap_pvt_thread_mutex_lock( &slapi_time_mutex );
1046 gettimeofday( &base_time, NULL );
1048 gettimeofday( &now, NULL );
1049 ret = ( now.tv_sec - base_time.tv_sec ) * 1000000 +
1050 (now.tv_usec - base_time.tv_usec);
1051 ldap_pvt_thread_mutex_unlock( &slapi_time_mutex );
1057 return (slap_get_time() - starttime) * 1000000;
1064 performance_counter_present = QueryPerformanceCounter( &base_time );
1065 QueryPerformanceFrequency( &performance_freq );
1068 if ( !performance_counter_present )
1071 QueryPerformanceCounter( &now );
1072 return (1000000*(now.QuadPart-base_time.QuadPart))/performance_freq.QuadPart;
1074 #else /* !defined(LDAP_SLAPI) */
1076 #endif /* !defined(LDAP_SLAPI) */
1083 slapi_timer_get_time( char *label )
1085 #if defined(LDAP_SLAPI)
1086 unsigned long start = slapi_timer_current_time();
1087 printf("%10ld %10ld usec %s\n", start, 0, label);
1089 #else /* !defined(LDAP_SLAPI) */
1091 #endif /* !defined(LDAP_SLAPI) */
1098 slapi_timer_elapsed_time(
1100 unsigned long start )
1102 #if defined(LDAP_SLAPI)
1103 unsigned long stop = slapi_timer_current_time();
1104 printf ("%10ld %10ld usec %s\n", stop, stop - start, label);
1105 #endif /* defined(LDAP_SLAPI) */
1109 slapi_free_search_results_internal( Slapi_PBlock *pb )
1111 #if defined(LDAP_SLAPI)
1112 Slapi_Entry **entries;
1113 int k = 0, nEnt = 0;
1115 slapi_pblock_get( pb, SLAPI_NENTRIES, &nEnt );
1116 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries );
1121 if ( entries == NULL ) {
1125 for ( k = 0; k < nEnt; k++ ) {
1126 slapi_entry_free( entries[k] );
1129 slapi_ch_free( entries );
1130 #endif /* defined(LDAP_SLAPI) */
1134 * Internal API to prime a Slapi_PBlock with a Connection.
1136 void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
1138 #if defined(LDAP_SLAPI)
1142 slapi_pblock_set(pb, SLAPI_CONNECTION, conn);
1143 slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid);
1144 switch (conn->c_authz.sai_method) {
1145 case LDAP_AUTH_SASL:
1146 len = sizeof(SLAPD_AUTH_SASL) + conn->c_authz.sai_mech.bv_len;
1147 connAuthType = slapi_ch_malloc(len);
1148 snprintf(connAuthType, len, "%s%s", SLAPD_AUTH_SASL, conn->c_authz.sai_mech.bv_val);
1150 case LDAP_AUTH_SIMPLE:
1151 connAuthType = slapi_ch_strdup(SLAPD_AUTH_SIMPLE);
1153 case LDAP_AUTH_NONE:
1154 connAuthType = slapi_ch_strdup(SLAPD_AUTH_NONE);
1157 connAuthType = NULL;
1160 if (conn->c_is_tls && connAuthType == NULL) {
1161 connAuthType = slapi_ch_strdup(SLAPD_AUTH_SSL);
1163 if (connAuthType != NULL) {
1164 slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, connAuthType);
1166 if (conn->c_authz.sai_dn.bv_val != NULL) {
1167 slapi_pblock_set(pb, SLAPI_CONN_DN, slapi_ch_strdup(conn->c_authz.sai_dn.bv_val));
1169 #endif /* defined(LDAP_SLAPI) */
1172 int slapi_is_connection_ssl( Slapi_PBlock *pb, int *isSSL )
1174 #if defined( LDAP_SLAPI )
1177 slapi_pblock_get( pb, SLAPI_CONNECTION, &conn );
1178 *isSSL = conn->c_is_tls;
1180 return LDAP_SUCCESS;
1183 #endif /* defined(LDAP_SLAPI) */