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