shdocvw: Get rid of WebBrowser dependency in DocHost object.
[wine.git] / dlls / wldap32 / modify.c
blob55ac77605a61c79e7d187495b1323b727d1ce82e
1 /*
2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 static LDAPMod *nullmods[] = { NULL };
35 #else
36 #define LDAP_NOT_SUPPORTED 0x5c
37 #endif
39 #include "winldap_private.h"
40 #include "wldap32.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 ULONG ldap_modifyA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
46 ULONG ret = LDAP_NOT_SUPPORTED;
47 #ifdef HAVE_LDAP
48 WCHAR *dnW = NULL;
49 LDAPModW **modsW = NULL;
51 ret = WLDAP32_LDAP_NO_MEMORY;
53 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
55 if (!ld) return ~0UL;
57 if (dn) {
58 dnW = strAtoW( dn );
59 if (!dnW) goto exit;
61 if (mods) {
62 modsW = modarrayAtoW( mods );
63 if (!modsW) goto exit;
66 ret = ldap_modifyW( ld, dnW, modsW );
68 exit:
69 strfreeW( dnW );
70 modarrayfreeW( modsW );
72 #endif
73 return ret;
76 ULONG ldap_modifyW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
78 ULONG ret = LDAP_NOT_SUPPORTED;
79 #ifdef HAVE_LDAP
80 char *dnU = NULL;
81 LDAPMod **modsU = NULL;
82 int msg;
84 ret = WLDAP32_LDAP_NO_MEMORY;
86 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
88 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
90 if (dn) {
91 dnU = strWtoU( dn );
92 if (!dnU) goto exit;
94 if (mods) {
95 modsU = modarrayWtoU( mods );
96 if (!modsU) goto exit;
99 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods,
100 NULL, NULL, &msg );
102 if (ret == LDAP_SUCCESS)
103 ret = msg;
104 else
105 ret = ~0UL;
107 exit:
108 strfreeU( dnU );
109 modarrayfreeU( modsU );
111 #endif
112 return ret;
115 ULONG ldap_modify_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
116 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
118 ULONG ret = LDAP_NOT_SUPPORTED;
119 #ifdef HAVE_LDAP
120 WCHAR *dnW = NULL;
121 LDAPModW **modsW = NULL;
122 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
124 ret = WLDAP32_LDAP_NO_MEMORY;
126 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
127 serverctrls, clientctrls, message );
129 if (!ld) return ~0UL;
131 if (dn) {
132 dnW = strAtoW( dn );
133 if (!dnW) goto exit;
135 if (mods) {
136 modsW = modarrayAtoW( mods );
137 if (!modsW) goto exit;
139 if (serverctrls) {
140 serverctrlsW = controlarrayAtoW( serverctrls );
141 if (!serverctrlsW) goto exit;
143 if (clientctrls) {
144 clientctrlsW = controlarrayAtoW( clientctrls );
145 if (!clientctrlsW) goto exit;
148 ret = ldap_modify_extW( ld, dnW, modsW, serverctrlsW, clientctrlsW, message );
150 exit:
151 strfreeW( dnW );
152 modarrayfreeW( modsW );
153 controlarrayfreeW( serverctrlsW );
154 controlarrayfreeW( clientctrlsW );
156 #endif
157 return ret;
160 ULONG ldap_modify_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
161 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
163 ULONG ret = LDAP_NOT_SUPPORTED;
164 #ifdef HAVE_LDAP
165 char *dnU = NULL;
166 LDAPMod **modsU = NULL;
167 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
168 int dummy;
170 ret = WLDAP32_LDAP_NO_MEMORY;
172 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
173 serverctrls, clientctrls, message );
175 if (!ld) return ~0UL;
177 if (dn) {
178 dnU = strWtoU( dn );
179 if (!dnU) goto exit;
181 if (mods) {
182 modsU = modarrayWtoU( mods );
183 if (!modsU) goto exit;
185 if (serverctrls) {
186 serverctrlsU = controlarrayWtoU( serverctrls );
187 if (!serverctrlsU) goto exit;
189 if (clientctrls) {
190 clientctrlsU = controlarrayWtoU( clientctrls );
191 if (!clientctrlsU) goto exit;
194 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods, serverctrlsU,
195 clientctrlsU, message ? (int *)message : &dummy );
197 exit:
198 strfreeU( dnU );
199 modarrayfreeU( modsU );
200 controlarrayfreeU( serverctrlsU );
201 controlarrayfreeU( clientctrlsU );
203 #endif
204 return ret;
207 ULONG ldap_modify_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
208 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
210 ULONG ret = LDAP_NOT_SUPPORTED;
211 #ifdef HAVE_LDAP
212 WCHAR *dnW = NULL;
213 LDAPModW **modsW = NULL;
214 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
216 ret = WLDAP32_LDAP_NO_MEMORY;
218 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
219 serverctrls, clientctrls );
221 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
223 if (dn) {
224 dnW = strAtoW( dn );
225 if (!dnW) goto exit;
227 if (mods) {
228 modsW = modarrayAtoW( mods );
229 if (!modsW) goto exit;
231 if (serverctrls) {
232 serverctrlsW = controlarrayAtoW( serverctrls );
233 if (!serverctrlsW) goto exit;
235 if (clientctrls) {
236 clientctrlsW = controlarrayAtoW( clientctrls );
237 if (!clientctrlsW) goto exit;
240 ret = ldap_modify_ext_sW( ld, dnW, modsW, serverctrlsW, clientctrlsW );
242 exit:
243 strfreeW( dnW );
244 modarrayfreeW( modsW );
245 controlarrayfreeW( serverctrlsW );
246 controlarrayfreeW( clientctrlsW );
248 #endif
249 return ret;
252 ULONG ldap_modify_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
253 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
255 ULONG ret = LDAP_NOT_SUPPORTED;
256 #ifdef HAVE_LDAP
257 char *dnU = NULL;
258 LDAPMod **modsU = NULL;
259 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
261 ret = WLDAP32_LDAP_NO_MEMORY;
263 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
264 serverctrls, clientctrls );
266 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
268 if (dn) {
269 dnU = strWtoU( dn );
270 if (!dnU) goto exit;
272 if (mods) {
273 modsU = modarrayWtoU( mods );
274 if (!modsU) goto exit;
276 if (serverctrls) {
277 serverctrlsU = controlarrayWtoU( serverctrls );
278 if (!serverctrlsU) goto exit;
280 if (clientctrls) {
281 clientctrlsU = controlarrayWtoU( clientctrls );
282 if (!clientctrlsU) goto exit;
285 ret = ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods,
286 serverctrlsU, clientctrlsU );
288 exit:
289 strfreeU( dnU );
290 modarrayfreeU( modsU );
291 controlarrayfreeU( serverctrlsU );
292 controlarrayfreeU( clientctrlsU );
294 #endif
295 return ret;
298 ULONG ldap_modify_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
300 ULONG ret = LDAP_NOT_SUPPORTED;
301 #ifdef HAVE_LDAP
302 WCHAR *dnW = NULL;
303 LDAPModW **modsW = NULL;
305 ret = WLDAP32_LDAP_NO_MEMORY;
307 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
309 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
311 if (dn) {
312 dnW = strAtoW( dn );
313 if (!dnW) goto exit;
315 if (mods) {
316 modsW = modarrayAtoW( mods );
317 if (!modsW) goto exit;
320 ret = ldap_modify_sW( ld, dnW, modsW );
322 exit:
323 strfreeW( dnW );
324 modarrayfreeW( modsW );
326 #endif
327 return ret;
330 ULONG ldap_modify_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
332 ULONG ret = LDAP_NOT_SUPPORTED;
333 #ifdef HAVE_LDAP
334 char *dnU = NULL;
335 LDAPMod **modsU = NULL;
337 ret = WLDAP32_LDAP_NO_MEMORY;
339 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
341 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
343 if (dn) {
344 dnU = strWtoU( dn );
345 if (!dnU) goto exit;
347 if (mods) {
348 modsU = modarrayWtoU( mods );
349 if (!modsU) goto exit;
352 ret = ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods, NULL, NULL );
354 exit:
355 strfreeU( dnU );
356 modarrayfreeU( modsU );
358 #endif
359 return ret;