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
22 #include "wine/port.h"
33 #include "winldap_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
40 static LDAPMod
*nullmods
[] = { NULL
};
43 /***********************************************************************
44 * ldap_modifyA (WLDAP32.@)
48 ULONG CDECL
ldap_modifyA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
50 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
53 LDAPModW
**modsW
= NULL
;
55 ret
= WLDAP32_LDAP_NO_MEMORY
;
57 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
66 modsW
= modarrayAtoW( mods
);
67 if (!modsW
) goto exit
;
70 ret
= ldap_modifyW( ld
, dnW
, modsW
);
74 modarrayfreeW( modsW
);
80 /***********************************************************************
81 * ldap_modifyW (WLDAP32.@)
83 * Change an entry in a directory tree (asynchronous operation).
86 * ld [I] Pointer to an LDAP context.
87 * dn [I] DN of the entry to change.
88 * mods [I] Pointer to an array of LDAPModW structures, each
89 * specifying an attribute and its values to change.
92 * Success: Message ID of the modify operation.
93 * Failure: An LDAP error code.
96 * Call ldap_result with the message ID to get the result of
97 * the operation. Cancel the operation by calling ldap_abandon
98 * with the message ID.
100 ULONG CDECL
ldap_modifyW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
102 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
105 LDAPMod
**modsU
= NULL
;
108 ret
= WLDAP32_LDAP_NO_MEMORY
;
110 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
112 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
119 modsU
= modarrayWtoU( mods
);
120 if (!modsU
) goto exit
;
123 ret
= ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
126 if (ret
== LDAP_SUCCESS
)
133 modarrayfreeU( modsU
);
139 /***********************************************************************
140 * ldap_modify_extA (WLDAP32.@)
142 * See ldap_modify_extW.
144 ULONG CDECL
ldap_modify_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
145 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
147 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
150 LDAPModW
**modsW
= NULL
;
151 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
153 ret
= WLDAP32_LDAP_NO_MEMORY
;
155 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
156 serverctrls
, clientctrls
, message
);
165 modsW
= modarrayAtoW( mods
);
166 if (!modsW
) goto exit
;
169 serverctrlsW
= controlarrayAtoW( serverctrls
);
170 if (!serverctrlsW
) goto exit
;
173 clientctrlsW
= controlarrayAtoW( clientctrls
);
174 if (!clientctrlsW
) goto exit
;
177 ret
= ldap_modify_extW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
, message
);
181 modarrayfreeW( modsW
);
182 controlarrayfreeW( serverctrlsW
);
183 controlarrayfreeW( clientctrlsW
);
189 /***********************************************************************
190 * ldap_modify_extW (WLDAP32.@)
192 * Change an entry in a directory tree (asynchronous operation).
195 * ld [I] Pointer to an LDAP context.
196 * dn [I] DN of the entry to change.
197 * mods [I] Pointer to an array of LDAPModW structures, each
198 * specifying an attribute and its values to change.
199 * serverctrls [I] Array of LDAP server controls.
200 * clientctrls [I] Array of LDAP client controls.
201 * message [O] Message ID of the modify operation.
204 * Success: LDAP_SUCCESS
205 * Failure: An LDAP error code.
208 * Call ldap_result with the message ID to get the result of
209 * the operation. The serverctrls and clientctrls parameters are
210 * optional and should be set to NULL if not used.
212 ULONG CDECL
ldap_modify_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
213 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
215 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
218 LDAPMod
**modsU
= NULL
;
219 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
222 ret
= WLDAP32_LDAP_NO_MEMORY
;
224 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
225 serverctrls
, clientctrls
, message
);
234 modsU
= modarrayWtoU( mods
);
235 if (!modsU
) goto exit
;
238 serverctrlsU
= controlarrayWtoU( serverctrls
);
239 if (!serverctrlsU
) goto exit
;
242 clientctrlsU
= controlarrayWtoU( clientctrls
);
243 if (!clientctrlsU
) goto exit
;
246 ret
= map_error( ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, serverctrlsU
,
247 clientctrlsU
, message
? (int *)message
: &dummy
));
251 modarrayfreeU( modsU
);
252 controlarrayfreeU( serverctrlsU
);
253 controlarrayfreeU( clientctrlsU
);
259 /***********************************************************************
260 * ldap_modify_ext_sA (WLDAP32.@)
262 * See ldap_modify_ext_sW.
264 ULONG CDECL
ldap_modify_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
265 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
267 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
270 LDAPModW
**modsW
= NULL
;
271 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
273 ret
= WLDAP32_LDAP_NO_MEMORY
;
275 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
276 serverctrls
, clientctrls
);
278 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
285 modsW
= modarrayAtoW( mods
);
286 if (!modsW
) goto exit
;
289 serverctrlsW
= controlarrayAtoW( serverctrls
);
290 if (!serverctrlsW
) goto exit
;
293 clientctrlsW
= controlarrayAtoW( clientctrls
);
294 if (!clientctrlsW
) goto exit
;
297 ret
= ldap_modify_ext_sW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
);
301 modarrayfreeW( modsW
);
302 controlarrayfreeW( serverctrlsW
);
303 controlarrayfreeW( clientctrlsW
);
309 /***********************************************************************
310 * ldap_modify_ext_sW (WLDAP32.@)
312 * Change an entry in a directory tree (synchronous operation).
315 * ld [I] Pointer to an LDAP context.
316 * dn [I] DN of the entry to change.
317 * mods [I] Pointer to an array of LDAPModW structures, each
318 * specifying an attribute and its values to change.
319 * serverctrls [I] Array of LDAP server controls.
320 * clientctrls [I] Array of LDAP client controls.
323 * Success: LDAP_SUCCESS
324 * Failure: An LDAP error code.
327 * The serverctrls and clientctrls parameters are optional and
328 * should be set to NULL if not used.
330 ULONG CDECL
ldap_modify_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
331 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
333 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
336 LDAPMod
**modsU
= NULL
;
337 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
339 ret
= WLDAP32_LDAP_NO_MEMORY
;
341 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
342 serverctrls
, clientctrls
);
344 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
351 modsU
= modarrayWtoU( mods
);
352 if (!modsU
) goto exit
;
355 serverctrlsU
= controlarrayWtoU( serverctrls
);
356 if (!serverctrlsU
) goto exit
;
359 clientctrlsU
= controlarrayWtoU( clientctrls
);
360 if (!clientctrlsU
) goto exit
;
363 ret
= map_error( ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
364 serverctrlsU
, clientctrlsU
));
368 modarrayfreeU( modsU
);
369 controlarrayfreeU( serverctrlsU
);
370 controlarrayfreeU( clientctrlsU
);
376 /***********************************************************************
377 * ldap_modify_sA (WLDAP32.@)
379 * See ldap_modify_sW.
381 ULONG CDECL
ldap_modify_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
383 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
386 LDAPModW
**modsW
= NULL
;
388 ret
= WLDAP32_LDAP_NO_MEMORY
;
390 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
392 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
399 modsW
= modarrayAtoW( mods
);
400 if (!modsW
) goto exit
;
403 ret
= ldap_modify_sW( ld
, dnW
, modsW
);
407 modarrayfreeW( modsW
);
413 /***********************************************************************
414 * ldap_modify_sW (WLDAP32.@)
416 * Change an entry in a directory tree (synchronous operation).
419 * ld [I] Pointer to an LDAP context.
420 * dn [I] DN of the entry to change.
421 * attrs [I] Pointer to an array of LDAPModW structures, each
422 * specifying an attribute and its values to change.
425 * Success: LDAP_SUCCESS
426 * Failure: An LDAP error code.
428 ULONG CDECL
ldap_modify_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
430 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
433 LDAPMod
**modsU
= NULL
;
435 ret
= WLDAP32_LDAP_NO_MEMORY
;
437 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
439 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
446 modsU
= modarrayWtoU( mods
);
447 if (!modsU
) goto exit
;
450 ret
= map_error( ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, NULL
, NULL
));
454 modarrayfreeU( modsU
);