1 /* modify.c - shell backend modify function */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
29 struct shellinfo *si = (struct shellinfo *) be->be_private;
33 if ( si->si_modify == NULL ) {
34 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
35 "modify not implemented", NULL, NULL );
39 if ( (op->o_private = (void *) forkandexec( si->si_modify, &rfp, &wfp ))
41 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
42 "could not fork/exec", NULL, NULL );
46 /* write out the request to the modify process */
47 fprintf( wfp, "MODIFY\n" );
48 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
49 print_suffixes( wfp, be );
50 fprintf( wfp, "dn: %s\n", dn );
51 for ( ; ml != NULL; ml = ml->sml_next ) {
54 /* FIXME: should use LDIF routines to deal with binary data */
56 switch ( mod->sm_op ) {
58 fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname.bv_val );
62 fprintf( wfp, "delete: %s\n", mod->sm_desc->ad_cname.bv_val );
65 case LDAP_MOD_REPLACE:
66 fprintf( wfp, "replace: %s\n", mod->sm_desc->ad_cname.bv_val );
70 if( mod->sm_bvalues != NULL ) {
71 for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
72 fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname.bv_val,
73 mod->sm_bvalues[i]->bv_val /* binary! */ );
77 fprintf( wfp, "-\n" );
81 /* read in the results and send them along */
82 read_and_send_results( be, conn, op, rfp, NULL, 0 );