1 /* bind.c - sock backend bind function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2007-2013 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>.
17 * This work was initially developed by Brian Candler for inclusion
18 * in OpenLDAP Software.
25 #include <ac/socket.h>
26 #include <ac/string.h>
29 #include "back-sock.h"
36 struct sockinfo *si = (struct sockinfo *) op->o_bd->be_private;
37 AttributeDescription *entry = slap_schema.si_ad_entry;
43 e.e_name = op->o_req_dn;
44 e.e_nname = op->o_req_ndn;
51 if ( ! access_allowed( op, &e,
52 entry, NULL, ACL_AUTH, NULL ) )
54 send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL );
58 if ( (fp = opensock( si->si_sockpath )) == NULL ) {
59 send_ldap_error( op, rs, LDAP_OTHER,
60 "could not open socket" );
64 /* write out the request to the bind process */
65 fprintf( fp, "BIND\n" );
66 fprintf( fp, "msgid: %ld\n", (long) op->o_msgid );
67 sock_print_conn( fp, op->o_conn, si );
68 sock_print_suffixes( fp, op->o_bd );
69 fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val );
70 fprintf( fp, "method: %d\n", op->oq_bind.rb_method );
71 fprintf( fp, "credlen: %lu\n", op->oq_bind.rb_cred.bv_len );
72 fprintf( fp, "cred: %s\n", op->oq_bind.rb_cred.bv_val ); /* XXX */
75 /* read in the results and send them along */
76 rc = sock_read_and_send_results( op, rs, fp );