X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fmodify.c;h=d7ca681bed89c94cb9d41afe5287ac11918144c8;hb=refs%2Fheads%2FOPENLDAP_AC;hp=583f919ddbdcf7260be09b3d7f06ba7007a78f36;hpb=669b8f4047c03d4583a44ed8287d0d5920d15373;p=openldap diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index 583f919ddb..d7ca681bed 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -1,12 +1,22 @@ -/* - * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ -/* Portions - * Copyright (c) 1990 Regents of the University of Michigan. - * All rights reserved. +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. * - * modify.c + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* Portions Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + */ +/* Portions Copyright (C) The Internet Society (1997) + * ASN.1 fragments are from RFC 2251; see RFC for full legal notices. */ #include "portable.h" @@ -36,7 +46,9 @@ * Example: * LDAPMod *mods[] = { * { LDAP_MOD_ADD, "cn", { "babs jensen", "babs", 0 } }, - * { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } }, + * { LDAP_MOD_REPLACE, "sn", { "babs jensen", "babs", 0 } }, + * { LDAP_MOD_DELETE, "ou", 0 }, + * { LDAP_MOD_INCREMENT, "uidNumber, { "1", 0 } } * 0 * } * rc= ldap_modify_ext( ld, dn, mods, sctrls, cctrls, &msgid ); @@ -51,6 +63,7 @@ ldap_modify_ext( LDAP *ld, { BerElement *ber; int i, rc; + ber_int_t id; /* * A modify request looks like this: @@ -59,8 +72,9 @@ ldap_modify_ext( LDAP *ld, * modifications SEQUENCE OF SEQUENCE { * operation ENUMERATED { * add (0), - * delete (1), - * replace (2) + * delete (1), + * replace (2), + * increment (3) -- extension * }, * modification SEQUENCE { * type AttributeType, @@ -72,13 +86,18 @@ ldap_modify_ext( LDAP *ld, Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 ); + /* check client controls */ + rc = ldap_int_client_controls( ld, cctrls ); + if( rc != LDAP_SUCCESS ) return rc; + /* create a message to send */ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { return( LDAP_NO_MEMORY ); } - if ( ber_printf( ber, "{it{s{" /*}}}*/, ++ld->ld_msgid, LDAP_REQ_MODIFY, dn ) - == -1 ) { + LDAP_NEXT_MSGID( ld, id ); + rc = ber_printf( ber, "{it{s{" /*}}}*/, id, LDAP_REQ_MODIFY, dn ); + if ( rc == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); return( ld->ld_errno ); @@ -87,11 +106,11 @@ ldap_modify_ext( LDAP *ld, /* for each modification to be performed... */ for ( i = 0; mods[i] != NULL; i++ ) { if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { - rc = ber_printf( ber, "{e{s[V]}}", + rc = ber_printf( ber, "{e{s[V]N}N}", (ber_int_t) ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ), mods[i]->mod_type, mods[i]->mod_bvalues ); } else { - rc = ber_printf( ber, "{e{s[v]}}", + rc = ber_printf( ber, "{e{s[v]N}N}", (ber_int_t) mods[i]->mod_op, mods[i]->mod_type, mods[i]->mod_values ); } @@ -103,7 +122,7 @@ ldap_modify_ext( LDAP *ld, } } - if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) { + if ( ber_printf( ber, /*{{*/ "N}N}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); return( ld->ld_errno ); @@ -115,14 +134,14 @@ ldap_modify_ext( LDAP *ld, return ld->ld_errno; } - if ( ber_printf( ber, /*{*/ "}" ) == -1 ) { + if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); return( ld->ld_errno ); } /* send the message */ - *msgidp = ldap_send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber ); + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber, id ); return( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS ); } @@ -140,7 +159,9 @@ ldap_modify_ext( LDAP *ld, * Example: * LDAPMod *mods[] = { * { LDAP_MOD_ADD, "cn", { "babs jensen", "babs", 0 } }, - * { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } }, + * { LDAP_MOD_REPLACE, "sn", { "babs jensen", "babs", 0 } }, + * { LDAP_MOD_DELETE, "ou", 0 }, + * { LDAP_MOD_INCREMENT, "uidNumber, { "1", 0 } } * 0 * } * msgid = ldap_modify( ld, dn, mods );