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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
24 #include "wine/debug.h"
36 #ifndef LDAP_NOT_SUPPORTED
37 #define LDAP_NOT_SUPPORTED 0x5c
40 #include "winldap_private.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
46 static LDAPMod
*nullmods
[] = { NULL
};
49 /***********************************************************************
50 * ldap_modifyA (WLDAP32.@)
54 ULONG CDECL
ldap_modifyA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
56 ULONG ret
= LDAP_NOT_SUPPORTED
;
59 LDAPModW
**modsW
= NULL
;
61 ret
= WLDAP32_LDAP_NO_MEMORY
;
63 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
72 modsW
= modarrayAtoW( mods
);
73 if (!modsW
) goto exit
;
76 ret
= ldap_modifyW( ld
, dnW
, modsW
);
80 modarrayfreeW( modsW
);
86 /***********************************************************************
87 * ldap_modifyW (WLDAP32.@)
89 * Change an entry in a directory tree (asynchronous operation).
92 * ld [I] Pointer to an LDAP context.
93 * dn [I] DN of the entry to change.
94 * mods [I] Pointer to an array of LDAPModW structures, each
95 * specifying an attribute and its values to change.
98 * Success: Message ID of the modify operation.
99 * Failure: An LDAP error code.
102 * Call ldap_result with the message ID to get the result of
103 * the operation. Cancel the operation by calling ldap_abandon
104 * with the message ID.
106 ULONG CDECL
ldap_modifyW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
108 ULONG ret
= LDAP_NOT_SUPPORTED
;
111 LDAPMod
**modsU
= NULL
;
114 ret
= WLDAP32_LDAP_NO_MEMORY
;
116 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
118 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
125 modsU
= modarrayWtoU( mods
);
126 if (!modsU
) goto exit
;
129 ret
= ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
132 if (ret
== LDAP_SUCCESS
)
139 modarrayfreeU( modsU
);
145 /***********************************************************************
146 * ldap_modify_extA (WLDAP32.@)
148 * See ldap_modify_extW.
150 ULONG CDECL
ldap_modify_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
151 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
153 ULONG ret
= LDAP_NOT_SUPPORTED
;
156 LDAPModW
**modsW
= NULL
;
157 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
159 ret
= WLDAP32_LDAP_NO_MEMORY
;
161 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
162 serverctrls
, clientctrls
, message
);
164 if (!ld
) return ~0UL;
171 modsW
= modarrayAtoW( mods
);
172 if (!modsW
) goto exit
;
175 serverctrlsW
= controlarrayAtoW( serverctrls
);
176 if (!serverctrlsW
) goto exit
;
179 clientctrlsW
= controlarrayAtoW( clientctrls
);
180 if (!clientctrlsW
) goto exit
;
183 ret
= ldap_modify_extW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
, message
);
187 modarrayfreeW( modsW
);
188 controlarrayfreeW( serverctrlsW
);
189 controlarrayfreeW( clientctrlsW
);
195 /***********************************************************************
196 * ldap_modify_extW (WLDAP32.@)
198 * Change an entry in a directory tree (asynchronous operation).
201 * ld [I] Pointer to an LDAP context.
202 * dn [I] DN of the entry to change.
203 * mods [I] Pointer to an array of LDAPModW structures, each
204 * specifying an attribute and its values to change.
205 * serverctrls [I] Array of LDAP server controls.
206 * clientctrls [I] Array of LDAP client controls.
207 * message [O] Message ID of the modify operation.
210 * Success: LDAP_SUCCESS
211 * Failure: An LDAP error code.
214 * Call ldap_result with the message ID to get the result of
215 * the operation. The serverctrls and clientctrls parameters are
216 * optional and should be set to NULL if not used.
218 ULONG CDECL
ldap_modify_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
219 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
221 ULONG ret
= LDAP_NOT_SUPPORTED
;
224 LDAPMod
**modsU
= NULL
;
225 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
228 ret
= WLDAP32_LDAP_NO_MEMORY
;
230 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
231 serverctrls
, clientctrls
, message
);
233 if (!ld
) return ~0UL;
240 modsU
= modarrayWtoU( mods
);
241 if (!modsU
) goto exit
;
244 serverctrlsU
= controlarrayWtoU( serverctrls
);
245 if (!serverctrlsU
) goto exit
;
248 clientctrlsU
= controlarrayWtoU( clientctrls
);
249 if (!clientctrlsU
) goto exit
;
252 ret
= ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, serverctrlsU
,
253 clientctrlsU
, message
? (int *)message
: &dummy
);
257 modarrayfreeU( modsU
);
258 controlarrayfreeU( serverctrlsU
);
259 controlarrayfreeU( clientctrlsU
);
265 /***********************************************************************
266 * ldap_modify_ext_sA (WLDAP32.@)
268 * See ldap_modify_ext_sW.
270 ULONG CDECL
ldap_modify_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
271 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
273 ULONG ret
= LDAP_NOT_SUPPORTED
;
276 LDAPModW
**modsW
= NULL
;
277 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
279 ret
= WLDAP32_LDAP_NO_MEMORY
;
281 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
282 serverctrls
, clientctrls
);
284 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
291 modsW
= modarrayAtoW( mods
);
292 if (!modsW
) goto exit
;
295 serverctrlsW
= controlarrayAtoW( serverctrls
);
296 if (!serverctrlsW
) goto exit
;
299 clientctrlsW
= controlarrayAtoW( clientctrls
);
300 if (!clientctrlsW
) goto exit
;
303 ret
= ldap_modify_ext_sW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
);
307 modarrayfreeW( modsW
);
308 controlarrayfreeW( serverctrlsW
);
309 controlarrayfreeW( clientctrlsW
);
315 /***********************************************************************
316 * ldap_modify_ext_sW (WLDAP32.@)
318 * Change an entry in a directory tree (synchronous operation).
321 * ld [I] Pointer to an LDAP context.
322 * dn [I] DN of the entry to change.
323 * mods [I] Pointer to an array of LDAPModW structures, each
324 * specifying an attribute and its values to change.
325 * serverctrls [I] Array of LDAP server controls.
326 * clientctrls [I] Array of LDAP client controls.
329 * Success: LDAP_SUCCESS
330 * Failure: An LDAP error code.
333 * The serverctrls and clientctrls parameters are optional and
334 * should be set to NULL if not used.
336 ULONG CDECL
ldap_modify_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
337 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
339 ULONG ret
= LDAP_NOT_SUPPORTED
;
342 LDAPMod
**modsU
= NULL
;
343 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
345 ret
= WLDAP32_LDAP_NO_MEMORY
;
347 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
348 serverctrls
, clientctrls
);
350 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
357 modsU
= modarrayWtoU( mods
);
358 if (!modsU
) goto exit
;
361 serverctrlsU
= controlarrayWtoU( serverctrls
);
362 if (!serverctrlsU
) goto exit
;
365 clientctrlsU
= controlarrayWtoU( clientctrls
);
366 if (!clientctrlsU
) goto exit
;
369 ret
= ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
370 serverctrlsU
, clientctrlsU
);
374 modarrayfreeU( modsU
);
375 controlarrayfreeU( serverctrlsU
);
376 controlarrayfreeU( clientctrlsU
);
382 /***********************************************************************
383 * ldap_modify_sA (WLDAP32.@)
385 * See ldap_modify_sW.
387 ULONG CDECL
ldap_modify_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
389 ULONG ret
= LDAP_NOT_SUPPORTED
;
392 LDAPModW
**modsW
= NULL
;
394 ret
= WLDAP32_LDAP_NO_MEMORY
;
396 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
398 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
405 modsW
= modarrayAtoW( mods
);
406 if (!modsW
) goto exit
;
409 ret
= ldap_modify_sW( ld
, dnW
, modsW
);
413 modarrayfreeW( modsW
);
419 /***********************************************************************
420 * ldap_modify_sW (WLDAP32.@)
422 * Change an entry in a directory tree (synchronous operation).
425 * ld [I] Pointer to an LDAP context.
426 * dn [I] DN of the entry to change.
427 * attrs [I] Pointer to an array of LDAPModW structures, each
428 * specifying an attribute and its values to change.
431 * Success: LDAP_SUCCESS
432 * Failure: An LDAP error code.
434 ULONG CDECL
ldap_modify_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
436 ULONG ret
= LDAP_NOT_SUPPORTED
;
439 LDAPMod
**modsU
= NULL
;
441 ret
= WLDAP32_LDAP_NO_MEMORY
;
443 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
445 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
452 modsU
= modarrayWtoU( mods
);
453 if (!modsU
) goto exit
;
456 ret
= ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, NULL
, NULL
);
460 modarrayfreeU( modsU
);