1 /* init.c - initialize ldap backend */
4 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 /* This is an altered version */
9 * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
11 * Permission is granted to anyone to use this software for any purpose
12 * on any computer system, and to alter it and redistribute it, subject
13 * to the following restrictions:
15 * 1. The author is not responsible for the consequences of use of this
16 * software, no matter how awful, even if they arise from flaws in it.
18 * 2. The origin of this software must not be misrepresented, either by
19 * explicit claim or by omission. Since few users ever read sources,
20 * credits should appear in the documentation.
22 * 3. Altered versions must be plainly marked as such, and must not be
23 * misrepresented as being the original software. Since few users
24 * ever read sources, credits should appear in the documentation.
26 * 4. This notice may not be removed or altered.
30 * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
32 * This software is being modified by Pierangelo Masarati.
33 * The previously reported conditions apply to the modified code as well.
34 * Changes in the original code are highlighted where required.
35 * Credits for the original code go to the author, Howard Chu.
42 #include <ac/socket.h>
45 #include "back-ldap.h"
47 #ifdef SLAPD_LDAP_DYNAMIC
49 int back_ldap_LTX_init_module(int argc, char *argv[]) {
52 memset( &bi, '\0', sizeof(bi) );
54 bi.bi_init = ldap_back_initialize;
60 #endif /* SLAPD_LDAP_DYNAMIC */
72 bi->bi_db_init = ldap_back_db_init;
73 bi->bi_db_config = ldap_back_db_config;
76 bi->bi_db_destroy = ldap_back_db_destroy;
79 bi->bi_op_bind = ldap_back_bind;
81 bi->bi_op_search = ldap_back_search;
82 bi->bi_op_compare = ldap_back_compare;
83 bi->bi_op_modify = ldap_back_modify;
84 bi->bi_op_modrdn = ldap_back_modrdn;
85 bi->bi_op_add = ldap_back_add;
86 bi->bi_op_delete = ldap_back_delete;
87 bi->bi_op_abandon = 0;
91 bi->bi_acl_group = ldap_back_group;
92 bi->bi_acl_attribute = ldap_back_attribute;
93 bi->bi_chk_referrals = 0;
95 bi->bi_connection_init = 0;
96 bi->bi_connection_destroy = ldap_back_conn_destroy;
107 struct ldapmapping *mapping;
109 li = (struct ldapinfo *) ch_calloc( 1, sizeof(struct ldapinfo) );
114 #ifdef ENABLE_REWRITE
115 li->rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
116 if ( li->rwinfo == NULL ) {
120 #endif /* ENABLE_REWRITE */
122 ldap_pvt_thread_mutex_init( &li->conn_mutex );
124 mapping = (struct ldapmapping *)ch_calloc( 2, sizeof(struct ldapmapping) );
125 if ( mapping != NULL ) {
126 mapping->src = ch_strdup("objectclass");
127 mapping->dst = ch_strdup("objectclass");
128 mapping[1].src = mapping->src;
129 mapping[1].dst = mapping->dst;
131 avl_insert( &li->at_map.map, (caddr_t)mapping,
132 mapping_cmp, mapping_dup );
133 avl_insert( &li->at_map.remap, (caddr_t)&mapping[1],
134 mapping_cmp, mapping_dup );
148 if ( lc->bound_dn) free( lc->bound_dn );
153 mapping_free ( struct ldapmapping *mapping )
155 ch_free( mapping->src );
156 ch_free( mapping->dst );
161 ldap_back_db_destroy(
167 if (be->be_private) {
168 li = (struct ldapinfo *)be->be_private;
170 ldap_pvt_thread_mutex_lock( &li->conn_mutex );
185 avl_free( li->conntree, (AVL_FREE) conn_free );
187 #ifdef ENABLE_REWRITE
189 rewrite_info_delete( li->rwinfo );
191 #else /* !ENABLE_REWRITE */
192 if (li->suffix_massage) {
193 ldap_value_free( li->suffix_massage );
195 #endif /* !ENABLE_REWRITE */
197 avl_free( li->oc_map.remap, NULL );
198 avl_free( li->oc_map.map, (AVL_FREE) mapping_free );
199 avl_free( li->at_map.remap, NULL );
200 avl_free( li->at_map.map, (AVL_FREE) mapping_free );
202 ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
203 ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
206 free( be->be_private );