Back to index

openldap  2.4.31
bind.c
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1999-2012 The OpenLDAP Foundation.
00005  * Portions Copyright 1999 John C. Quillan.
00006  * Portions Copyright 2002 myinternet Limited.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted only as authorized by the OpenLDAP
00011  * Public License.
00012  *
00013  * A copy of this license is available in file LICENSE in the
00014  * top-level directory of the distribution or, alternatively, at
00015  * <http://www.OpenLDAP.org/license.html>.
00016  */
00017 
00018 #include "perl_back.h"
00019 
00020 
00021 /**********************************************************
00022  *
00023  * Bind
00024  *
00025  **********************************************************/
00026 int
00027 perl_back_bind(
00028        Operation *op,
00029        SlapReply *rs )
00030 {
00031        int count;
00032 
00033        PerlBackend *perl_back = (PerlBackend *) op->o_bd->be_private;
00034 
00035        /* allow rootdn as a means to auth without the need to actually
00036         * contact the proxied DSA */
00037        switch ( be_rootdn_bind( op, rs ) ) {
00038        case SLAP_CB_CONTINUE:
00039               break;
00040 
00041        default:
00042               return rs->sr_err;
00043        }
00044 
00045        PERL_SET_CONTEXT( PERL_INTERPRETER );
00046        ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
00047 
00048        {
00049               dSP; ENTER; SAVETMPS;
00050 
00051               PUSHMARK(SP);
00052               XPUSHs( perl_back->pb_obj_ref );
00053               XPUSHs(sv_2mortal(newSVpv( op->o_req_dn.bv_val , op->o_req_dn.bv_len)));
00054               XPUSHs(sv_2mortal(newSVpv( op->orb_cred.bv_val , op->orb_cred.bv_len)));
00055               PUTBACK;
00056 
00057               count = call_method("bind", G_SCALAR);
00058 
00059               SPAGAIN;
00060 
00061               if (count != 1) {
00062                      croak("Big trouble in back_bind\n");
00063               }
00064 
00065               rs->sr_err = POPi;
00066                                                   
00067 
00068               PUTBACK; FREETMPS; LEAVE;
00069        }
00070 
00071        ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );       
00072 
00073        Debug( LDAP_DEBUG_ANY, "Perl BIND returned 0x%04x\n", rs->sr_err, 0, 0 );
00074 
00075        /* frontend will send result on success (0) */
00076        if( rs->sr_err != LDAP_SUCCESS )
00077               send_ldap_result( op, rs );
00078 
00079        return ( rs->sr_err );
00080 }