]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/init.c
unifdef -DSLAPD_ACLGROUPS -DSLAPD_ACLAUTH
[openldap] / servers / slapd / back-ldap / init.c
1 /* init.c - initialize ldap backend */
2
3 /*
4  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
5  * 
6  * Permission is granted to anyone to use this software for any purpose
7  * on any computer system, and to alter it and redistribute it, subject
8  * to the following restrictions:
9  * 
10  * 1. The author is not responsible for the consequences of use of this
11  *    software, no matter how awful, even if they arise from flaws in it.
12  * 
13  * 2. The origin of this software must not be misrepresented, either by
14  *    explicit claim or by omission.  Since few users ever read sources,
15  *    credits should appear in the documentation.
16  * 
17  * 3. Altered versions must be plainly marked as such, and must not be
18  *    misrepresented as being the original software.  Since few users
19  *    ever read sources, credits should appear in the documentation.
20  * 
21  * 4. This notice may not be removed or altered.
22  */
23
24 #include "portable.h"
25
26 #include <stdio.h>
27
28 #include <ac/socket.h>
29
30 #include "slap.h"
31 #include "back-ldap.h"
32
33 #ifdef SLAPD_LDAP_DYNAMIC
34 #include <gmodule.h>
35
36 G_MODULE_EXPORT void init_module(int argc, char *argv[]) {
37    BackendInfo bi;
38
39    bi.bi_type = "ldap";
40    bi.bi_init = ldap_back_initialize;
41
42    backend_add(&bi);
43 }
44
45 #endif /* SLAPD_LDAP_DYNAMIC */
46
47 int
48 ldap_back_initialize(
49     BackendInfo *bi
50 )
51 {
52         bi->bi_open = 0;
53         bi->bi_config = 0;
54         bi->bi_close = 0;
55         bi->bi_destroy = 0;
56
57         bi->bi_db_init = ldap_back_db_init;
58         bi->bi_db_config = ldap_back_db_config;
59         bi->bi_db_open = 0;
60         bi->bi_db_close = 0;
61         bi->bi_db_destroy = ldap_back_db_destroy;
62
63         bi->bi_op_bind = ldap_back_bind;
64         bi->bi_op_unbind = ldap_back_unbind;
65         bi->bi_op_search = ldap_back_search;
66         bi->bi_op_compare = ldap_back_compare;
67         bi->bi_op_modify = ldap_back_modify;
68         bi->bi_op_modrdn = ldap_back_modrdn;
69         bi->bi_op_add = ldap_back_add;
70         bi->bi_op_delete = ldap_back_delete;
71         bi->bi_op_abandon = 0;
72
73         bi->bi_acl_group = 0;
74
75         bi->bi_connection_init = 0;
76         bi->bi_connection_destroy = 0;
77
78         return 0;
79 }
80
81 int
82 ldap_back_db_init(
83     Backend     *be
84 )
85 {
86         struct ldapinfo *li;
87
88         li = (struct ldapinfo *) ch_calloc( 1, sizeof(struct ldapinfo) );
89         ldap_pvt_thread_mutex_init( &li->conn_mutex );
90
91         be->be_private = li;
92
93         return li == NULL;
94 }
95
96 int
97 ldap_back_db_destroy(
98     Backend     *be
99 )
100 {
101         struct ldapinfo *li;
102
103         if (be->be_private) {
104                 li = (struct ldapinfo *)be->be_private;
105                 if (li->host) {
106                         free(li->host);
107                         li->host = NULL;
108                 }
109                 ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
110         }
111
112         free( be->be_private );
113         return 0;
114 }