]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/bind.c
f246c2f26ee94e519e13102b443b59e62a5b24fb
[openldap] / servers / slapd / back-perl / bind.c
1 /* $OpenLDAP$ */
2 /*
3  *       Copyright 1999, John C. Quillan, All rights reserved.
4  *       Portions Copyright 2002, myinternet pty ltd. All rights reserved.
5  *
6  *       Redistribution and use in source and binary forms are permitted only
7  *       as authorized by the OpenLDAP Public License.  A copy of this
8  *       license is available at http://www.OpenLDAP.org/license.html or
9  *       in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #include "portable.h"
13 /* init.c - initialize shell backend */
14         
15 #include <stdio.h>
16 /*      #include <ac/types.h>
17         #include <ac/socket.h>
18 */
19
20 #include <EXTERN.h>
21 #include <perl.h>
22
23 #include "slap.h"
24 #include "perl_back.h"
25
26
27 /**********************************************************
28  *
29  * Bind
30  *
31  **********************************************************/
32 int
33 perl_back_bind(
34         Backend *be,
35         Connection *conn,
36         Operation *op,
37         struct berval *dn,
38         struct berval *ndn,
39         int method,
40         struct berval *cred,
41         struct berval *edn
42 )
43 {
44         int return_code;
45         int count;
46
47         PerlBackend *perl_back = (PerlBackend *) be->be_private;
48
49         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
50
51         {
52                 dSP; ENTER; SAVETMPS;
53
54                 PUSHMARK(sp);
55                 XPUSHs( perl_back->pb_obj_ref );
56                 XPUSHs(sv_2mortal(newSVpv( dn->bv_val , 0)));
57                 XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len)));
58                 PUTBACK;
59
60 #ifdef PERL_IS_5_6
61                 count = call_method("bind", G_SCALAR);
62 #else
63                 count = perl_call_method("bind", G_SCALAR);
64 #endif
65
66                 SPAGAIN;
67
68                 if (count != 1) {
69                         croak("Big trouble in back_bind\n");
70                 }
71
72                 return_code = POPi;
73                                                          
74
75                 PUTBACK; FREETMPS; LEAVE;
76         }
77
78         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
79
80         Debug( LDAP_DEBUG_ANY, "Perl BIND\n", 0, 0, 0 );
81
82         return ( return_code );
83 }