1 /* bind.c - shell backend bind function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
27 * This work was originally developed by the University of Michigan
28 * (as part of U-MICH LDAP).
35 #include <ac/socket.h>
36 #include <ac/string.h>
46 struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
47 AttributeDescription *entry = slap_schema.si_ad_entry;
52 if ( si->si_bind == NULL ) {
53 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
54 "bind not implemented" );
59 e.e_name = op->o_req_dn;
60 e.e_nname = op->o_req_ndn;
67 if ( ! access_allowed( op, &e,
68 entry, NULL, ACL_AUTH, NULL ) )
70 send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL );
74 if ( forkandexec( si->si_bind, &rfp, &wfp ) == (pid_t)-1 ) {
75 send_ldap_error( op, rs, LDAP_OTHER,
76 "could not fork/exec" );
80 /* write out the request to the bind process */
81 fprintf( wfp, "BIND\n" );
82 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
83 print_suffixes( wfp, op->o_bd );
84 fprintf( wfp, "dn: %s\n", op->o_req_dn.bv_val );
85 fprintf( wfp, "method: %d\n", op->oq_bind.rb_method );
86 fprintf( wfp, "credlen: %lu\n", op->oq_bind.rb_cred.bv_len );
87 fprintf( wfp, "cred: %s\n", op->oq_bind.rb_cred.bv_val ); /* XXX */
90 /* read in the results and send them along */
91 rc = read_and_send_results( op, rs, rfp );