]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_modify.3
Sync with HEAD
[openldap] / doc / man / man3 / ldap_modify.3
1 .TH LDAP_MODIFY 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldap_modify, ldap_modify_s \- Perform an LDAP modify operation
7 .SH LIBRARY
8 OpenLDAP LDAP (libldap, -lldap)
9 .SH SYNOPSIS
10 .nf
11 .ft B
12 #include <ldap.h>
13 .LP
14 .ft B
15 .nf
16 int ldap_modify(ld, dn, mods)
17 .ft
18 LDAP *ld;
19 char *dn;
20 LDAPMod *mods[];
21 .LP
22 .ft B
23 .nf
24 int ldap_modify_s(ld, dn, mods)
25 .ft
26 LDAP *ld;
27 char *dn;
28 LDAPMod *mods[];
29 .LP
30 .ft B
31 .nf
32 void ldap_mods_free( mods, freemods )
33 .ft
34 LDAPMod **mods;
35 int freemods;
36 .SH DESCRIPTION
37 The routine
38 .B ldap_modify_s()
39 is used to perform an LDAP modify operation.
40 \fIdn\fP is the DN of the entry to modify, and \fImods\fP is a
41 null-terminated array of modifications to make to the entry.  Each element
42 of the \fImods\fP array is a pointer to an LDAPMod structure, which is
43 defined below.
44 .LP
45 .nf
46 .ft B
47         typedef struct ldapmod {
48             int mod_op;
49             char *mod_type;
50             union {
51                 char **modv_strvals;
52                 struct berval **modv_bvals;
53             } mod_vals;
54             struct ldapmod *mod_next;
55         } LDAPMod;
56         #define mod_values mod_vals.modv_strvals
57         #define mod_bvalues mod_vals.modv_bvals
58 .ft
59 .fi
60 .LP
61 The \fImod_op\fP field is used to specify the type of modification to
62 perform and should be one of LDAP_MOD_ADD, LDAP_MOD_DELETE, or
63 LDAP_MOD_REPLACE.  The \fImod_type\fP and \fImod_values\fP fields
64 specify the attribute type to modify and a null-terminated array of
65 values to add, delete, or replace respectively.  The \fImod_next\fP
66 field is used only by the LDAP server and may be ignored by the
67 client.
68 .LP
69 If you need to specify a non-string value (e.g., to add a
70 photo or audio attribute value), you should set \fImod_op\fP to the
71 logical OR of the operation as above (e.g., LDAP_MOD_REPLACE)
72 and the constant LDAP_MOD_BVALUES.  In this case, \fImod_bvalues\fP
73 should be used instead of \fImod_values\fP, and it should point to
74 a null-terminated array of struct bervals, as defined in <lber.h>.
75 .LP
76 For LDAP_MOD_ADD modifications, the given values are added to the
77 entry, creating the attribute if necessary.  For LDAP_MOD_DELETE
78 modifications, the given values are deleted from the entry, removing
79 the attribute if no values remain.  If the entire attribute is to be deleted,
80 the \fImod_values\fP field should be set to NULL.  For LDAP_MOD_REPLACE
81 modifications, the attribute will have the listed values after the
82 modification, having been created if necessary.  All modifications are
83 performed in the order in which they are listed.
84 .LP
85 .B
86 ldap_modify_s()
87 returns the LDAP error code resulting from the
88 modify operation.  This code can be interpreted by
89 .BR ldap_perror (3)
90 and friends.
91 .LP
92 The
93 .B ldap_modify()
94 operation works the same way as
95 .BR ldap_modify_s() ,
96 except that it is asynchronous, returning the message id of the
97 request it initiates, or -1 on error.  The result of the operation
98 can be obtained by calling
99 .BR ldap_result (3).
100 .LP
101 .B ldap_mods_free()
102 can be used to free each element of a NULL-terminated
103 array of mod structures.  If \fIfreemods\fP is non-zero, the
104 \fImods\fP pointer itself is freed as well.
105 .SH ERRORS
106 .B ldap_modify_s()
107 returns an ldap error code, either LDAP_SUCCESS or
108 an error if there was trouble.
109 .B ldap_modify()
110 returns -1 in case
111 of trouble, setting the
112 .B ld_errno
113 field of \fIld\fP.
114 .SH SEE ALSO
115 .BR ldap (3),
116 .BR ldap_error (3),
117 .BR ldap_add (3)
118 .SH ACKNOWLEDGEMENTS
119 .B OpenLDAP
120 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
121 .B OpenLDAP
122 is derived from University of Michigan LDAP 3.3 Release.