Back to index

openldap  2.4.31
init.c
Go to the documentation of this file.
00001 /* init.c - initialize passwd backend */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #include "portable.h"
00018 
00019 #include <stdio.h>
00020 
00021 #include <ac/socket.h>
00022 
00023 #include "slap.h"
00024 #include "back-passwd.h"
00025 
00026 ldap_pvt_thread_mutex_t passwd_mutex;
00027 
00028 AttributeDescription *ad_sn;
00029 AttributeDescription *ad_desc;
00030 
00031 static BI_db_init passwd_back_db_init;
00032 
00033 int
00034 passwd_back_initialize(
00035     BackendInfo      *bi
00036 )
00037 {
00038        ldap_pvt_thread_mutex_init( &passwd_mutex );
00039 
00040        bi->bi_open = passwd_back_open;
00041        bi->bi_config = 0;
00042        bi->bi_close = 0;
00043        bi->bi_destroy = passwd_back_destroy;
00044 
00045        bi->bi_db_init = passwd_back_db_init;
00046        bi->bi_db_config = 0;
00047        bi->bi_db_open = 0;
00048        bi->bi_db_close = 0;
00049        bi->bi_db_destroy = 0;
00050 
00051        bi->bi_op_bind = 0;
00052        bi->bi_op_unbind = 0;
00053        bi->bi_op_search = passwd_back_search;
00054        bi->bi_op_compare = 0;
00055        bi->bi_op_modify = 0;
00056        bi->bi_op_modrdn = 0;
00057        bi->bi_op_add = 0;
00058        bi->bi_op_delete = 0;
00059        bi->bi_op_abandon = 0;
00060 
00061        bi->bi_extended = 0;
00062 
00063        bi->bi_chk_referrals = 0;
00064 
00065        bi->bi_connection_init = 0;
00066        bi->bi_connection_destroy = 0;
00067 
00068        return passwd_back_init_cf( bi );
00069 }
00070 
00071 int
00072 passwd_back_open(
00073        BackendInfo *bi
00074 )
00075 {
00076        const char    *text;
00077        int           rc;
00078 
00079        rc = slap_str2ad( "sn", &ad_sn, &text );
00080        if ( rc != LDAP_SUCCESS ) {
00081               Debug( LDAP_DEBUG_ANY, "passwd_back_open: "
00082                      "slap_str2ad(\"%s\") returned %d: %s\n",
00083                      "sn", rc, text );
00084               return -1;
00085        }
00086        rc = slap_str2ad( "description", &ad_desc, &text );
00087        if ( rc != LDAP_SUCCESS ) {
00088               Debug( LDAP_DEBUG_ANY, "passwd_back_open: "
00089                      "slap_str2ad(\"%s\") returned %d: %s\n",
00090                      "description", rc, text );
00091               return -1;
00092        }
00093 
00094        return 0;
00095 }
00096 
00097 int
00098 passwd_back_destroy(
00099        BackendInfo *bi
00100 )
00101 {
00102        ldap_pvt_thread_mutex_destroy( &passwd_mutex );
00103        return 0;
00104 }
00105 
00106 static int
00107 passwd_back_db_init(
00108        Backend *be,
00109        struct config_reply_s *cr
00110 )
00111 {
00112        be->be_cf_ocs = be->bd_info->bi_cf_ocs;
00113        return 0;
00114 }
00115 
00116 #if SLAPD_PASSWD == SLAPD_MOD_DYNAMIC
00117 
00118 /* conditionally define the init_module() function */
00119 SLAP_BACKEND_INIT_MODULE( passwd )
00120 
00121 #endif /* SLAPD_PASSWD == SLAPD_MOD_DYNAMIC */
00122