27 #if defined( INC_ALL )
37 #if defined( _MSC_VER )
38 #pragma message( " Building with LDAP enabled." )
45 #define MAX_DN_STRINGSIZE 1024
46 #define MAX_LDAP_ATTRIBUTES 20
52 #if defined( __WINDOWS__ )
59 #define LDAP_API LDAPAPI
60 #define timeval l_timeval
61 #elif defined( NETSCAPE_CLIENT )
63 #define LDAP_API LDAP_CALL
64 #define ber_free ldap_ber_free
90 static INSTANCE_HANDLE hLDAP = NULL_INSTANCE;
92 typedef void ( LDAP_API *BER_FREE )( BerElement *ber,
int freebuf );
93 typedef int ( LDAP_API *LDAP_ADD_S )( LDAP *ld,
const char *dn, LDAPMod **attrs );
94 typedef int ( LDAP_API *LDAP_DELETE_S )( LDAP *ld,
const char *dn );
95 typedef char * ( LDAP_API *LDAP_ERR2STRING )(
int err );
96 typedef char * ( LDAP_API *LDAP_FIRST_ATTRIBUTE )( LDAP *ld, LDAPMessage *entry,
98 typedef LDAPMessage * ( LDAP_API *LDAP_FIRST_ENTRY )( LDAP *ld, LDAPMessage *result );
99 #if defined( __WINDOWS__ )
100 typedef int ( LDAP_API *LDAP_GETLASTERROR )( void );
101 #elif defined( NETSCAPE_CLIENT )
102 typedef int ( LDAP_API *LDAP_GET_LDERRNO )( LDAP *ld,
char **m,
char **
s );
104 typedef int ( LDAP_API *LDAP_GET_OPTION )( LDAP *ld,
int option,
void *outvalue );
106 typedef struct berval ** ( LDAP_API *LDAP_GET_VALUES_LEN )( LDAP *ld, LDAPMessage *entry,
108 typedef LDAP * ( LDAP_API *LDAP_INIT )(
const char *host,
int port );
109 typedef int ( LDAP_API *LDAP_IS_LDAP_URL )(
char *url );
110 typedef void ( LDAP_API *LDAP_MEMFREE )(
void *
p );
111 typedef void ( LDAP_API *LDAP_MODSFREE )( LDAPMod **mods,
int freemods );
112 typedef int ( LDAP_API *LDAP_MSGFREE )( LDAPMessage *lm );
113 typedef LDAPMessage * ( LDAP_API *LDAP_NEXT_ENTRY )( LDAP *ld, LDAPMessage *result );
114 typedef int ( LDAP_API *LDAP_SEARCH_ST )( LDAP *ld,
const char *base,
int scope,
115 const char *filter,
char **attrs,
116 int attrsonly,
struct timeval *timeout,
118 typedef int ( LDAP_API *LDAP_SET_OPTION )( LDAP *ld,
int option,
void *optdata );
119 typedef int ( LDAP_API *LDAP_SIMPLE_BIND_S )( LDAP *ld,
const char *who,
120 const char *passwd );
121 typedef int ( LDAP_API *LDAP_UNBIND )( LDAP *ld );
122 typedef int ( LDAP_API *LDAP_URL_SEARCH_ST )( LDAP *ld,
char *url,
int attrsonly,
123 struct timeval *timeout,
125 typedef void ( LDAP_API *LDAP_VALUE_FREE_LEN )(
struct berval **vals );
126 #if defined( __WINDOWS__ ) || defined( NETSCAPE_CLIENT )
127 static BER_FREE p_ber_free = NULL;
129 static LDAP_ADD_S p_ldap_add_s = NULL;
130 static LDAP_DELETE_S p_ldap_delete_s = NULL;
131 static LDAP_ERR2STRING p_ldap_err2string = NULL;
132 static LDAP_FIRST_ATTRIBUTE p_ldap_first_attribute = NULL;
133 static LDAP_FIRST_ENTRY p_ldap_first_entry = NULL;
134 #if defined( __WINDOWS__ )
135 static LDAP_GETLASTERROR p_LdapGetLastError = NULL;
136 #elif defined( NETSCAPE_CLIENT )
137 static LDAP_GET_LDERRNO p_ldap_get_lderrno = NULL;
139 static LDAP_GET_OPTION p_ldap_get_option = NULL;
141 static LDAP_GET_VALUES_LEN p_ldap_get_values_len = NULL;
142 static LDAP_INIT p_ldap_init = NULL;
143 static LDAP_IS_LDAP_URL p_ldap_is_ldap_url = NULL;
144 static LDAP_MEMFREE p_ldap_memfree = NULL;
145 static LDAP_NEXT_ENTRY p_ldap_next_entry = NULL;
146 static LDAP_MSGFREE p_ldap_msgfree = NULL;
147 static LDAP_SEARCH_ST p_ldap_search_st = NULL;
148 static LDAP_SET_OPTION p_ldap_set_option = NULL;
149 static LDAP_SIMPLE_BIND_S p_ldap_simple_bind_s = NULL;
150 static LDAP_UNBIND p_ldap_unbind = NULL;
151 static LDAP_URL_SEARCH_ST p_ldap_url_search_st = NULL;
152 static LDAP_VALUE_FREE_LEN p_ldap_value_free_len = NULL;
159 #define ber_free p_ber_free
160 #define ldap_add_s p_ldap_add_s
161 #define ldap_delete_s p_ldap_delete_s
162 #define ldap_err2string p_ldap_err2string
163 #define ldap_first_attribute p_ldap_first_attribute
164 #define ldap_first_entry p_ldap_first_entry
165 #if defined( __WINDOWS__ )
166 #define LdapGetLastError p_LdapGetLastError
167 #elif defined( NETSCAPE_CLIENT )
168 #define ldap_get_lderrno p_ldap_get_lderrno
170 #define ldap_get_option p_ldap_get_option
172 #define ldap_get_values_len p_ldap_get_values_len
173 #define ldap_init p_ldap_init
174 #define ldap_is_ldap_url p_ldap_is_ldap_url
175 #define ldap_memfree p_ldap_memfree
176 #define ldap_msgfree p_ldap_msgfree
177 #define ldap_next_entry p_ldap_next_entry
178 #define ldap_search_st p_ldap_search_st
179 #define ldap_set_option p_ldap_set_option
180 #define ldap_simple_bind_s p_ldap_simple_bind_s
181 #define ldap_unbind p_ldap_unbind
182 #define ldap_url_search_st p_ldap_url_search_st
183 #define ldap_value_free_len p_ldap_value_free_len
188 #define LDAP_LIBNAME "NSLDSS16.DLL"
189 #elif defined( __WIN32__ )
190 #define LDAP_LIBNAME "wldap32.dll"
191 #elif defined( __UNIX__ )
192 #if defined( __APPLE__ )
194 #define LDAP_LIBNAME "libldap.dylib"
195 #elif defined NETSCAPE_CLIENT
196 #define LDAP_LIBNAME "libldap50.so"
198 #define LDAP_LIBNAME "libldap.so"
211 if( hLDAP != NULL_INSTANCE )
216 errorMode = SetErrorMode( SEM_NOOPENFILEERRORBOX );
217 hLDAP = LoadLibrary( LDAP_LIBNAME );
218 SetErrorMode( errorMode );
219 if( hLDAP < HINSTANCE_ERROR )
221 hLDAP = NULL_INSTANCE;
225 if( ( hLDAP = DynamicLoad( LDAP_LIBNAME ) ) == NULL_INSTANCE )
230 #if defined( __WINDOWS__ )
231 p_ber_free = ( BER_FREE ) DynamicBind( hLDAP,
"ber_free" );
232 #elif defined( NETSCAPE_CLIENT )
233 p_ber_free = ( BER_FREE ) DynamicBind( hLDAP,
"ldap_ber_free" );
235 p_ldap_add_s = ( LDAP_ADD_S ) DynamicBind( hLDAP,
"ldap_add_s" );
236 p_ldap_delete_s = ( LDAP_DELETE_S ) DynamicBind( hLDAP,
"ldap_delete_s" );
237 p_ldap_err2string = ( LDAP_ERR2STRING ) DynamicBind( hLDAP,
"ldap_err2string" );
238 p_ldap_first_attribute = ( LDAP_FIRST_ATTRIBUTE ) DynamicBind( hLDAP,
"ldap_first_attribute" );
239 p_ldap_first_entry = ( LDAP_FIRST_ENTRY ) DynamicBind( hLDAP,
"ldap_first_entry" );
240 #if defined( __WINDOWS__ )
241 p_LdapGetLastError = ( LDAP_GETLASTERROR ) DynamicBind( hLDAP,
"LdapGetLastError" );
242 #elif defined( NETSCAPE_CLIENT )
243 p_ldap_get_lderrno = ( LDAP_GET_LDERRNO ) DynamicBind( hLDAP,
"ldap_get_lderrno" );
245 p_ldap_get_option = ( LDAP_GET_OPTION ) DynamicBind( hLDAP,
"ldap_get_option" );
247 p_ldap_get_values_len = ( LDAP_GET_VALUES_LEN ) DynamicBind( hLDAP,
"ldap_get_values_len" );
248 p_ldap_init = ( LDAP_INIT ) DynamicBind( hLDAP,
"ldap_init" );
249 p_ldap_is_ldap_url = ( LDAP_IS_LDAP_URL ) DynamicBind( hLDAP,
"ldap_is_ldap_url" );
250 p_ldap_memfree = ( LDAP_MEMFREE ) DynamicBind( hLDAP,
"ldap_memfree" );
251 p_ldap_msgfree = ( LDAP_MSGFREE ) DynamicBind( hLDAP,
"ldap_msgfree" );
252 p_ldap_next_entry = ( LDAP_NEXT_ENTRY ) DynamicBind( hLDAP,
"ldap_next_entry" );
253 p_ldap_search_st = ( LDAP_SEARCH_ST ) DynamicBind( hLDAP,
"ldap_search_st" );
254 p_ldap_set_option = ( LDAP_SET_OPTION ) DynamicBind( hLDAP,
"ldap_set_option" );
255 p_ldap_simple_bind_s = ( LDAP_SIMPLE_BIND_S ) DynamicBind( hLDAP,
"ldap_simple_bind_s" );
256 p_ldap_unbind = ( LDAP_UNBIND ) DynamicBind( hLDAP,
"ldap_unbind" );
257 p_ldap_url_search_st = ( LDAP_URL_SEARCH_ST ) DynamicBind( hLDAP,
"ldap_url_search_st" );
258 p_ldap_value_free_len = ( LDAP_VALUE_FREE_LEN ) DynamicBind( hLDAP,
"ldap_value_free_len" );
261 if( p_ldap_add_s == NULL ||
262 #ifdef NETSCAPE_CLIENT
263 p_ber_free == NULL ||
265 p_ldap_delete_s == NULL || p_ldap_err2string == NULL || \
266 p_ldap_first_attribute == NULL || p_ldap_first_entry == NULL || \
267 p_ldap_init == NULL ||
268 #
if defined( __WINDOWS__ )
269 p_LdapGetLastError == NULL ||
270 #elif defined( NETSCAPE_CLIENT )
271 p_ldap_get_lderrno == NULL || p_ldap_is_ldap_url == NULL ||
272 p_ldap_url_search_st == NULL ||
274 p_ldap_get_option == NULL ||
276 p_ldap_get_values_len == NULL || p_ldap_memfree == NULL || \
277 p_ldap_msgfree == NULL || p_ldap_next_entry == NULL || \
278 p_ldap_search_st == NULL || p_ldap_set_option == NULL || \
279 p_ldap_simple_bind_s == NULL || p_ldap_unbind == NULL || \
280 p_ldap_value_free_len == NULL )
283 DynamicUnload( hLDAP );
284 hLDAP = NULL_INSTANCE;
291 if( p_ldap_url_search_st == NULL )
292 p_ldap_is_ldap_url = NULL;
299 if( hLDAP != NULL_INSTANCE )
300 DynamicUnload( hLDAP );
301 hLDAP = NULL_INSTANCE;
333 buffer[ msgData.
length ] =
'\0';
338 static void getErrorInfo(
KEYSET_INFO *keysetInfoPtr,
int ldapStatus )
342 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
347 #if defined( __WINDOWS__ )
348 errorCode = LdapGetLastError();
349 if( errorCode == LDAP_SUCCESS )
355 errorCode = ldapStatus;
357 errorMessage = ldap_err2string( errorCode );
363 errorCode = GetLastError();
364 FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
365 NULL, errorCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
368 #elif defined( NETSCAPE_CLIENT )
369 ldap_get_lderrno( ldapInfo->
ld, NULL, &errorMessage );
373 #ifdef LDAP_OPT_ERROR_NUMBER
374 ldap_get_option( ldapInfo->
ld, LDAP_OPT_ERROR_NUMBER, &errorCode );
376 ldap_get_option( ldapInfo->
ld, LDAP_OPT_RESULT_CODE, &errorCode );
378 ldap_get_option( ldapInfo->
ld, LDAP_OPT_ERROR_STRING, &errorMessage );
380 if( errorMessage != NULL )
382 setErrorString( errorInfo, errorMessage, strlen( errorMessage ) );
392 static int mapLdapError(
const int ldapError,
const int defaultError )
396 case LDAP_INAPPROPRIATE_AUTH:
397 case LDAP_INVALID_CREDENTIALS:
398 case LDAP_AUTH_UNKNOWN:
399 #if defined( __WINDOWS__ )
400 case LDAP_INSUFFICIENT_RIGHTS:
401 case LDAP_AUTH_METHOD_NOT_SUPPORTED:
402 #elif defined( NETSCAPE_CLIENT )
403 case LDAP_INSUFFICIENT_ACCESS:
405 case LDAP_INSUFFICIENT_ACCESS:
406 case LDAP_AUTH_METHOD_NOT_SUPPORTED:
410 #if defined( __WINDOWS__ )
411 case LDAP_ATTRIBUTE_OR_VALUE_EXISTS:
412 case LDAP_ALREADY_EXISTS:
413 #elif defined( NETSCAPE_CLIENT )
414 case LDAP_TYPE_OR_VALUE_EXISTS:
416 case LDAP_TYPE_OR_VALUE_EXISTS:
417 case LDAP_ALREADY_EXISTS:
421 #if defined( __WINDOWS__ )
422 case LDAP_CONFIDENTIALITY_REQUIRED:
423 #elif defined( NETSCAPE_CLIENT )
426 case LDAP_CONFIDENTIALITY_REQUIRED:
427 case LDAP_STRONG_AUTH_REQUIRED:
431 case LDAP_INVALID_DN_SYNTAX:
434 case LDAP_TIMELIMIT_EXCEEDED:
438 #ifndef NETSCAPE_CLIENT
439 case LDAP_NO_RESULTS_RETURNED:
441 case LDAP_NO_SUCH_ATTRIBUTE:
442 case LDAP_NO_SUCH_OBJECT:
445 #ifndef NETSCAPE_CLIENT
446 case LDAP_NOT_SUPPORTED:
447 case LDAP_UNAVAILABLE:
451 case LDAP_SIZELIMIT_EXCEEDED:
452 case LDAP_RESULTS_TOO_LARGE:
459 return( defaultError );
465 static LDAPMod *copyAttribute(
const char *attributeName,
466 const void *attributeValue,
472 if( ( ldapModPtr = ( LDAPMod * )
clAlloc(
"copyAttribute", \
473 sizeof( LDAPMod ) ) ) == NULL )
478 if( !attributeLength )
480 if( ( ldapModPtr->mod_values = \
482 2 *
sizeof(
void * ) ) ) == NULL )
484 clFree(
"copyAttribute", ldapModPtr );
487 ldapModPtr->mod_op = LDAP_MOD_ADD;
488 ldapModPtr->mod_type = (
char * ) attributeName;
489 ldapModPtr->mod_values[ 0 ] = (
char * ) attributeValue;
490 ldapModPtr->mod_values[ 1 ] = NULL;
494 if( ( ldapModPtr->mod_bvalues = \
496 2 *
sizeof(
struct berval ) ) ) == NULL )
498 clFree(
"copyAttribute", ldapModPtr );
501 ldapModPtr->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
502 ldapModPtr->mod_type = (
char * ) attributeName;
504 ldapModPtr->mod_bvalues[ 0 ]->bv_val = (
char * ) attributeValue;
505 ldapModPtr->mod_bvalues[ 1 ] = NULL;
508 return( ldapModPtr );
518 static void catComponent(
char *
dest,
const int destLen,
char *src )
523 for( i = 0; i < destLen && dest[ i ] !=
'\0'; i++ );
528 while( i < destLen - 1 && *src !=
'\0' )
530 const char ch = *src++;
543 static int encodeDN(
char *dn,
const int maxDnLen,
char *C,
char *SP,
544 char *L,
char *O,
char *OU,
char *CN )
547 catComponent( dn, maxDnLen, CN );
551 catComponent( dn, maxDnLen, OU );
556 catComponent( dn, maxDnLen, O );
561 catComponent( dn, maxDnLen, L );
566 catComponent( dn, maxDnLen, SP );
569 catComponent( dn, maxDnLen, C );
588 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
594 ldap_unbind( ldapInfo->
ld );
608 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
610 const char *ldapUser = NULL;
612 int maxEntries = 2, timeout, ldapPort, ldapStatus = LDAP_OTHER,
status;
626 status = sNetParseURL( &urlInfo, name, nameLength,
URL_TYPE_LDAP );
629 memcpy( ldapServer, urlInfo.host, urlInfo.
hostLen );
630 ldapServer[ urlInfo.
hostLen ] =
'\0';
631 ldapPort = ( urlInfo.
port > 0 ) ? urlInfo.
port : LDAP_PORT;
633 ldapUser = urlInfo.location;
636 if( ( ldapInfo->
ld = ldap_init( ldapServer, ldapPort ) ) == NULL )
638 if( ( ldapStatus = ldap_simple_bind_s( ldapInfo->
ld, ldapUser,
639 NULL ) ) != LDAP_SUCCESS )
641 getErrorInfo( keysetInfoPtr, ldapStatus );
642 ldap_unbind( ldapInfo->
ld );
659 ldap_set_option( ldapInfo->
ld, LDAP_OPT_TIMELIMIT, &timeout );
660 ldap_set_option( ldapInfo->
ld, LDAP_OPT_SIZELIMIT, &maxEntries );
663 assignFieldName( keysetInfoPtr->ownerHandle, ldapInfo->
nameObjectClass,
665 assignFieldName( keysetInfoPtr->ownerHandle, ldapInfo->
nameFilter,
667 assignFieldName( keysetInfoPtr->ownerHandle, ldapInfo->
nameCACert,
669 assignFieldName( keysetInfoPtr->ownerHandle, ldapInfo->
nameCert,
671 assignFieldName( keysetInfoPtr->ownerHandle, ldapInfo->
nameCRL,
673 assignFieldName( keysetInfoPtr->ownerHandle, ldapInfo->
nameEmail,
690 static int sendLdapQuery(
LDAP_INFO *ldapInfo, LDAPMessage **resultPtr,
695 const char *caCertAttributes[] = { ldapInfo->
nameCACert, NULL };
696 const char *crlAttributes[] = { ldapInfo->
nameCRL, NULL };
697 struct timeval ldapTimeout = { 0, 0 };
698 int ldapStatus = LDAP_OTHER, timeout;
704 ldapTimeout.tv_sec =
max( timeout, 15 );
708 if( ldap_is_ldap_url != NULL && ldap_is_ldap_url( (
char * ) dn ) )
710 return( ldap_url_search_st( ldapInfo->
ld, (
char * ) dn,
FALSE,
711 &ldapTimeout, resultPtr ) );
728 ldapStatus = ldap_search_st( ldapInfo->
ld, dn, LDAP_SCOPE_BASE,
730 (
char ** ) certAttributes, 0,
731 &ldapTimeout, resultPtr );
732 if( ldapStatus == LDAP_SUCCESS )
733 return( ldapStatus );
738 ldapStatus = ldap_search_st( ldapInfo->
ld, dn, LDAP_SCOPE_BASE,
740 (
char ** ) caCertAttributes, 0,
741 &ldapTimeout, resultPtr );
742 if( ldapStatus == LDAP_SUCCESS )
743 return( ldapStatus );
748 ldapStatus = ldap_search_st( ldapInfo->
ld, dn, LDAP_SCOPE_BASE,
750 (
char ** ) crlAttributes, 0,
751 &ldapTimeout, resultPtr );
752 if( ldapStatus == LDAP_SUCCESS )
753 return( ldapStatus );
756 return( ldapStatus );
773 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
776 struct berval **valuePtrs;
777 char dn[ MAX_DN_STRINGSIZE + 8 ];
783 assert(
isReadPtr( keyID, keyIDlength ) );
790 REQUIRES( auxInfo == NULL && *auxInfoLength == 0 );
794 if( keyIDlength > MAX_DN_STRINGSIZE - 1 )
796 memcpy( dn, keyID, keyIDlength );
800 ldapStatus = sendLdapQuery( ldapInfo, &result,
801 keysetInfoPtr->ownerHandle, dn );
802 if( ldapStatus != LDAP_SUCCESS )
804 getErrorInfo( keysetInfoPtr, ldapStatus );
809 if( ( resultEntry = ldap_first_entry( ldapInfo->
ld, result ) ) == NULL )
811 ldap_msgfree( result );
816 if( ( attributePtr = ldap_first_attribute( ldapInfo->
ld, resultEntry,
819 ldap_msgfree( result );
822 valuePtrs = ldap_get_values_len( ldapInfo->
ld, resultEntry,
824 if( valuePtrs != NULL )
830 valuePtrs[ 0 ]->bv_len,
838 ldap_value_free_len( valuePtrs );
890 #ifdef NETSCAPE_CLIENT
891 if( ber_free != NULL )
894 ldap_memfree( attributePtr );
895 ldap_msgfree( result );
911 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
912 LDAPMod *ldapMod[ MAX_LDAP_ATTRIBUTES + 8 ];
915 char dn[ MAX_DN_STRINGSIZE + 8 ];
922 *C = *SP = *L = *O = *OU = *CN = *email =
'\0';
934 C[ msgData.
length ] =
'\0';
942 SP[ msgData.
length ] =
'\0';
950 L[ msgData.
length ] =
'\0';
958 O[ msgData.
length ] =
'\0';
966 OU[ msgData.
length ] =
'\0';
974 CN[ msgData.
length ] =
'\0';
978 status = encodeDN( dn, MAX_DN_STRINGSIZE, C, SP, L, O, OU, CN );
991 keyDataLength = msgData.
length;
1005 "certPerson", 0 ) ) == NULL )
1007 if( ( ldapMod[ ldapModIndex++ ] = copyAttribute( ldapInfo->
nameCert,
1008 keyData, keyDataLength ) ) == NULL )
1013 ( ldapMod[ ldapModIndex++ ] = \
1014 copyAttribute( ldapInfo->
nameEmail, email, 0 ) ) == NULL )
1017 ( ldapMod[ ldapModIndex++ ] = copyAttribute(
"CN", CN, 0 ) ) == NULL )
1020 ( ldapMod[ ldapModIndex++ ] = copyAttribute(
"OU", OU, 0 ) ) == NULL )
1023 ( ldapMod[ ldapModIndex++ ] = copyAttribute(
"O", O, 0 ) ) == NULL )
1026 ( ldapMod[ ldapModIndex++ ] = copyAttribute(
"L", L, 0 ) ) == NULL )
1029 ( ldapMod[ ldapModIndex++ ] = copyAttribute(
"SP", SP, 0 ) ) == NULL )
1032 ( ldapMod[ ldapModIndex++ ] = copyAttribute(
"C", C, 0 ) ) == NULL )
1034 ldapMod[ ldapModIndex ] = NULL;
1041 if( ( ldapStatus = ldap_add_s( ldapInfo->
ld, dn,
1042 ldapMod ) ) != LDAP_SUCCESS )
1044 getErrorInfo( keysetInfoPtr, ldapStatus );
1056 for( ldapModIndex = 0; ldapModIndex < MAX_LDAP_ATTRIBUTES && \
1057 ldapMod[ ldapModIndex ] != NULL;
1060 if( ldapMod[ ldapModIndex ]->mod_op & LDAP_MOD_BVALUES )
1061 clFree(
"addCert", ldapMod[ ldapModIndex ]->mod_bvalues );
1063 clFree(
"addCert", ldapMod[ ldapModIndex ]->mod_values );
1064 clFree(
"addCert", ldapMod[ ldapModIndex ]->mod_values );
1065 clFree(
"addCert", ldapMod[ ldapModIndex ] );
1067 if( ldapModIndex >= MAX_LDAP_ATTRIBUTES )
1079 IN_FLAGS( KEYMGMT )
const int flags )
1089 REQUIRES( password == NULL && passwordLength == 0 );
1115 status = addCert( keysetInfoPtr, iCryptHandle );
1123 seenNonDuplicate =
TRUE;
1156 IN_BUFFER( keyIDlength )
const void *keyID,
1159 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
1160 char dn[ MAX_DN_STRINGSIZE + 8 ];
1164 assert(
isReadPtr( keyID, keyIDlength ) );
1173 if( keyIDlength > MAX_DN_STRINGSIZE - 1 )
1175 memcpy( dn, keyID, keyIDlength );
1179 if( ( ldapStatus = ldap_delete_s( ldapInfo->
ld, dn ) ) != LDAP_SUCCESS )
1181 getErrorInfo( keysetInfoPtr, ldapStatus );
1204 IN_BUFFER( keyIDlength )
const void *keyID,
1206 IN_FLAGS( KEYMGMT )
const int options )
1210 assert(
isReadPtr( keyID, keyIDlength ) );
1220 return( getItemFunction( keysetInfoPtr, iCertificate,
1222 keyID, keyIDlength, NULL, 0, 0 ) );
1229 IN_FLAGS( KEYMGMT )
const int options )
1238 return( getItemFunction( keysetInfoPtr, iCertificate,
1240 NULL, 0, NULL, 0, 0 ) );
1258 static void *getAttributeDataPtr(
KEYSET_INFO *keysetInfoPtr,
1261 LDAP_INFO *ldapInfo = keysetInfoPtr->keysetLDAP;
1292 const void *attributeDataPtr;
1298 attributeDataPtr = getAttributeDataPtr( keysetInfoPtr, type );
1299 if( attributeDataPtr == NULL )
1301 return( attributeCopy( data, attributeDataPtr,
1302 strlen( attributeDataPtr ) ) );
1311 BYTE *attributeDataPtr;
1317 attributeDataPtr = getAttributeDataPtr( keysetInfoPtr, type );
1318 if( attributeDataPtr == NULL )
1322 memcpy( attributeDataPtr, msgData->data, msgData->
length );
1323 attributeDataPtr[ msgData->
length ] =
'\0';
1337 if( hLDAP == NULL_INSTANCE )
1342 keysetInfoPtr->initFunction = initFunction;
1343 keysetInfoPtr->shutdownFunction = shutdownFunction;
1344 keysetInfoPtr->getAttributeFunction = getAttributeFunction;
1345 keysetInfoPtr->setAttributeFunction = setAttributeFunction;
1346 keysetInfoPtr->getItemFunction = getItemFunction;
1347 keysetInfoPtr->setItemFunction = setItemFunction;
1348 keysetInfoPtr->deleteItemFunction = deleteItemFunction;
1349 keysetInfoPtr->isBusyFunction = isBusyFunction;