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