Skip to content
Snippets Groups Projects
bind.c 1.88 KiB
Newer Older
  • Learn to ignore specific revisions
  • Kurt Zeilenga's avatar
    Kurt Zeilenga committed
    /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
     *
    
    Kurt Zeilenga's avatar
    Kurt Zeilenga committed
     * Copyright 1999-2011 The OpenLDAP Foundation.
    
    Kurt Zeilenga's avatar
    Kurt Zeilenga committed
     * Portions Copyright 1999 John C. Quillan.
     * Portions Copyright 2002 myinternet Limited.
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted only as authorized by the OpenLDAP
     * Public License.
    
    Kurt Zeilenga's avatar
    Kurt Zeilenga committed
     * A copy of this license is available in file LICENSE in the
     * top-level directory of the distribution or, alternatively, at
     * <http://www.OpenLDAP.org/license.html>.
    
     */
    
    #include "perl_back.h"
    
    
    /**********************************************************
     *
     * Bind
     *
     **********************************************************/
    int
    perl_back_bind(
    	Operation *op,
    
    Howard Chu's avatar
    Howard Chu committed
    	SlapReply *rs )
    
    Howard Chu's avatar
    Howard Chu committed
    	PerlBackend *perl_back = (PerlBackend *) op->o_bd->be_private;
    
    	/* allow rootdn as a means to auth without the need to actually
     	 * contact the proxied DSA */
    	switch ( be_rootdn_bind( op, rs ) ) {
    	case SLAP_CB_CONTINUE:
    		break;
    
    	default:
    		return rs->sr_err;
    	}
    
    
    #if defined(HAVE_WIN32_ASPERL) || defined(USE_ITHREADS)
    
    Luke Howard's avatar
    Luke Howard committed
    	PERL_SET_CONTEXT( PERL_INTERPRETER );
    #endif
    
    
    	ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );	
    
    Luke Howard's avatar
    Luke Howard committed
    		PUSHMARK(SP);
    
    		XPUSHs( perl_back->pb_obj_ref );
    
    Howard Chu's avatar
    Howard Chu committed
    		XPUSHs(sv_2mortal(newSVpv( op->o_req_dn.bv_val , 0)));
    		XPUSHs(sv_2mortal(newSVpv( op->orb_cred.bv_val , op->orb_cred.bv_len)));
    
    Luke Howard's avatar
    Luke Howard committed
    		count = call_method("bind", G_SCALAR);
    
    			croak("Big trouble in back_bind\n");
    
    Howard Chu's avatar
    Howard Chu committed
    		rs->sr_err = POPi;
    
    	ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );	
    
    Howard Chu's avatar
    Howard Chu committed
    	Debug( LDAP_DEBUG_ANY, "Perl BIND returned 0x%04x\n", rs->sr_err, 0, 0 );
    
    Luke Howard's avatar
    Luke Howard committed
    
    
    	/* frontend will send result on success (0) */
    
    Howard Chu's avatar
    Howard Chu committed
    	if( rs->sr_err != LDAP_SUCCESS )
    		send_ldap_result( op, rs );
    
    Howard Chu's avatar
    Howard Chu committed
    	return ( rs->sr_err );