]> git.sur5r.net Git - openldap/blob - servers/slapd/back-passwd/init.c
Happy new year! (belated)
[openldap] / servers / slapd / back-passwd / init.c
1 /* init.c - initialize passwd backend */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2008 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20
21 #include <ac/socket.h>
22
23 #include "slap.h"
24 #include "back-passwd.h"
25
26 ldap_pvt_thread_mutex_t passwd_mutex;
27
28 AttributeDescription *ad_sn;
29 AttributeDescription *ad_desc;
30
31 int
32 passwd_back_initialize(
33     BackendInfo *bi
34 )
35 {
36         ldap_pvt_thread_mutex_init( &passwd_mutex );
37
38         bi->bi_open = passwd_back_open;
39         bi->bi_config = 0;
40         bi->bi_close = 0;
41         bi->bi_destroy = passwd_back_destroy;
42
43         bi->bi_db_init = 0;
44         bi->bi_db_config = passwd_back_db_config;
45         bi->bi_db_open = 0;
46         bi->bi_db_close = 0;
47         bi->bi_db_destroy = 0;
48
49         bi->bi_op_bind = 0;
50         bi->bi_op_unbind = 0;
51         bi->bi_op_search = passwd_back_search;
52         bi->bi_op_compare = 0;
53         bi->bi_op_modify = 0;
54         bi->bi_op_modrdn = 0;
55         bi->bi_op_add = 0;
56         bi->bi_op_delete = 0;
57         bi->bi_op_abandon = 0;
58
59         bi->bi_extended = 0;
60
61         bi->bi_chk_referrals = 0;
62
63         bi->bi_connection_init = 0;
64         bi->bi_connection_destroy = 0;
65
66         return 0;
67 }
68
69 int
70 passwd_back_open(
71         BackendInfo *bi
72 )
73 {
74         const char      *text;
75         int             rc;
76
77         rc = slap_str2ad( "sn", &ad_sn, &text );
78         if ( rc != LDAP_SUCCESS ) {
79                 Debug( LDAP_DEBUG_ANY, "passwd_back_open: "
80                         "slap_str2ad(\"%s\") returned %d: %s\n",
81                         "sn", rc, text );
82                 return -1;
83         }
84         rc = slap_str2ad( "description", &ad_desc, &text );
85         if ( rc != LDAP_SUCCESS ) {
86                 Debug( LDAP_DEBUG_ANY, "passwd_back_open: "
87                         "slap_str2ad(\"%s\") returned %d: %s\n",
88                         "description", rc, text );
89                 return -1;
90         }
91
92         return 0;
93 }
94
95 int
96 passwd_back_destroy(
97         BackendInfo *bi
98 )
99 {
100         ldap_pvt_thread_mutex_destroy( &passwd_mutex );
101         return 0;
102 }
103
104 #if SLAPD_PASSWD == SLAPD_MOD_DYNAMIC
105
106 /* conditionally define the init_module() function */
107 SLAP_BACKEND_INIT_MODULE( passwd )
108
109 #endif /* SLAPD_PASSWD == SLAPD_MOD_DYNAMIC */
110