1 /* add.c - sock backend add function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2007 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>.
21 #include <ac/string.h>
22 #include <ac/socket.h>
25 #include "back-sock.h"
32 struct sockinfo *si = (struct sockinfo *) op->o_bd->be_private;
33 AttributeDescription *entry = slap_schema.si_ad_entry;
37 if ( ! access_allowed( op, op->oq_add.rs_e,
38 entry, NULL, ACL_WADD, NULL ) )
40 send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL );
44 if ( (fp = opensock( si->si_sockpath )) == NULL ) {
45 send_ldap_error( op, rs, LDAP_OTHER,
46 "could not open socket" );
50 /* write out the request to the add process */
51 fprintf( fp, "ADD\n" );
52 fprintf( fp, "msgid: %ld\n", (long) op->o_msgid );
53 sock_print_conn( fp, op->o_conn, si );
54 sock_print_suffixes( fp, op->o_bd );
55 ldap_pvt_thread_mutex_lock( &entry2str_mutex );
56 fprintf( fp, "%s", entry2str( op->oq_add.rs_e, &len ) );
57 ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
60 /* read in the result and send it along */
61 sock_read_and_send_results( op, rs, fp );