1 /* modrdn.c - shell backend modrdn function */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9 * LDAP v3 newSuperior support.
11 * Copyright 1999, Juan C. Gomez, All rights reserved.
12 * This software is not subject to any license of Silicon Graphics
13 * Inc. or Purdue University.
15 * Redistribution and use in source and binary forms are permitted
16 * without restriction or fee of any kind as long as this notice
25 #include <ac/socket.h>
26 #include <ac/string.h>
36 struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
37 AttributeDescription *entry = slap_schema.si_ad_entry;
41 if ( si->si_modrdn == NULL ) {
42 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
43 "modrdn not implemented" );
48 e.e_name = op->o_req_dn;
49 e.e_nname = op->o_req_ndn;
56 if ( ! access_allowed( op, &e,
57 entry, NULL, ACL_WRITE, NULL ) )
59 send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS, NULL );
63 if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp ))
65 send_ldap_error( op, rs, LDAP_OTHER,
66 "could not fork/exec" );
70 /* write out the request to the modrdn process */
71 fprintf( wfp, "MODRDN\n" );
72 fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
73 print_suffixes( wfp, op->o_bd );
74 fprintf( wfp, "dn: %s\n", op->o_req_dn.bv_val );
75 fprintf( wfp, "newrdn: %s\n", op->oq_modrdn.rs_newrdn.bv_val );
76 fprintf( wfp, "deleteoldrdn: %d\n", op->oq_modrdn.rs_deleteoldrdn ? 1 : 0 );
77 if (op->oq_modrdn.rs_newSup != NULL) {
78 fprintf( wfp, "newSuperior: %s\n", op->oq_modrdn.rs_newSup->bv_val );
82 /* read in the results and send them along */
83 read_and_send_results( op, rs, rfp );