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 #include "winldap_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
42 static LDAPMod
*nullmods
[] = { NULL
};
45 /***********************************************************************
46 * ldap_modifyA (WLDAP32.@)
50 ULONG CDECL
ldap_modifyA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
52 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
55 LDAPModW
**modsW
= NULL
;
57 ret
= WLDAP32_LDAP_NO_MEMORY
;
59 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
68 modsW
= modarrayAtoW( mods
);
69 if (!modsW
) goto exit
;
72 ret
= ldap_modifyW( ld
, dnW
, modsW
);
76 modarrayfreeW( modsW
);
82 /***********************************************************************
83 * ldap_modifyW (WLDAP32.@)
85 * Change an entry in a directory tree (asynchronous operation).
88 * ld [I] Pointer to an LDAP context.
89 * dn [I] DN of the entry to change.
90 * mods [I] Pointer to an array of LDAPModW structures, each
91 * specifying an attribute and its values to change.
94 * Success: Message ID of the modify operation.
95 * Failure: An LDAP error code.
98 * Call ldap_result with the message ID to get the result of
99 * the operation. Cancel the operation by calling ldap_abandon
100 * with the message ID.
102 ULONG CDECL
ldap_modifyW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
104 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
107 LDAPMod
**modsU
= NULL
;
110 ret
= WLDAP32_LDAP_NO_MEMORY
;
112 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
114 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
121 modsU
= modarrayWtoU( mods
);
122 if (!modsU
) goto exit
;
125 ret
= ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
128 if (ret
== LDAP_SUCCESS
)
135 modarrayfreeU( modsU
);
141 /***********************************************************************
142 * ldap_modify_extA (WLDAP32.@)
144 * See ldap_modify_extW.
146 ULONG CDECL
ldap_modify_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
147 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
149 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
152 LDAPModW
**modsW
= NULL
;
153 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
155 ret
= WLDAP32_LDAP_NO_MEMORY
;
157 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
158 serverctrls
, clientctrls
, message
);
160 if (!ld
) return ~0UL;
167 modsW
= modarrayAtoW( mods
);
168 if (!modsW
) goto exit
;
171 serverctrlsW
= controlarrayAtoW( serverctrls
);
172 if (!serverctrlsW
) goto exit
;
175 clientctrlsW
= controlarrayAtoW( clientctrls
);
176 if (!clientctrlsW
) goto exit
;
179 ret
= ldap_modify_extW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
, message
);
183 modarrayfreeW( modsW
);
184 controlarrayfreeW( serverctrlsW
);
185 controlarrayfreeW( clientctrlsW
);
191 /***********************************************************************
192 * ldap_modify_extW (WLDAP32.@)
194 * Change an entry in a directory tree (asynchronous operation).
197 * ld [I] Pointer to an LDAP context.
198 * dn [I] DN of the entry to change.
199 * mods [I] Pointer to an array of LDAPModW structures, each
200 * specifying an attribute and its values to change.
201 * serverctrls [I] Array of LDAP server controls.
202 * clientctrls [I] Array of LDAP client controls.
203 * message [O] Message ID of the modify operation.
206 * Success: LDAP_SUCCESS
207 * Failure: An LDAP error code.
210 * Call ldap_result with the message ID to get the result of
211 * the operation. The serverctrls and clientctrls parameters are
212 * optional and should be set to NULL if not used.
214 ULONG CDECL
ldap_modify_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
215 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
217 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
220 LDAPMod
**modsU
= NULL
;
221 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
224 ret
= WLDAP32_LDAP_NO_MEMORY
;
226 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
227 serverctrls
, clientctrls
, message
);
229 if (!ld
) return ~0UL;
236 modsU
= modarrayWtoU( mods
);
237 if (!modsU
) goto exit
;
240 serverctrlsU
= controlarrayWtoU( serverctrls
);
241 if (!serverctrlsU
) goto exit
;
244 clientctrlsU
= controlarrayWtoU( clientctrls
);
245 if (!clientctrlsU
) goto exit
;
248 ret
= map_error( ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, serverctrlsU
,
249 clientctrlsU
, message
? (int *)message
: &dummy
));
253 modarrayfreeU( modsU
);
254 controlarrayfreeU( serverctrlsU
);
255 controlarrayfreeU( clientctrlsU
);
261 /***********************************************************************
262 * ldap_modify_ext_sA (WLDAP32.@)
264 * See ldap_modify_ext_sW.
266 ULONG CDECL
ldap_modify_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
267 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
269 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
272 LDAPModW
**modsW
= NULL
;
273 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
275 ret
= WLDAP32_LDAP_NO_MEMORY
;
277 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
278 serverctrls
, clientctrls
);
280 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
287 modsW
= modarrayAtoW( mods
);
288 if (!modsW
) goto exit
;
291 serverctrlsW
= controlarrayAtoW( serverctrls
);
292 if (!serverctrlsW
) goto exit
;
295 clientctrlsW
= controlarrayAtoW( clientctrls
);
296 if (!clientctrlsW
) goto exit
;
299 ret
= ldap_modify_ext_sW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
);
303 modarrayfreeW( modsW
);
304 controlarrayfreeW( serverctrlsW
);
305 controlarrayfreeW( clientctrlsW
);
311 /***********************************************************************
312 * ldap_modify_ext_sW (WLDAP32.@)
314 * Change an entry in a directory tree (synchronous operation).
317 * ld [I] Pointer to an LDAP context.
318 * dn [I] DN of the entry to change.
319 * mods [I] Pointer to an array of LDAPModW structures, each
320 * specifying an attribute and its values to change.
321 * serverctrls [I] Array of LDAP server controls.
322 * clientctrls [I] Array of LDAP client controls.
325 * Success: LDAP_SUCCESS
326 * Failure: An LDAP error code.
329 * The serverctrls and clientctrls parameters are optional and
330 * should be set to NULL if not used.
332 ULONG CDECL
ldap_modify_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
333 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
335 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
338 LDAPMod
**modsU
= NULL
;
339 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
341 ret
= WLDAP32_LDAP_NO_MEMORY
;
343 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
344 serverctrls
, clientctrls
);
346 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
353 modsU
= modarrayWtoU( mods
);
354 if (!modsU
) goto exit
;
357 serverctrlsU
= controlarrayWtoU( serverctrls
);
358 if (!serverctrlsU
) goto exit
;
361 clientctrlsU
= controlarrayWtoU( clientctrls
);
362 if (!clientctrlsU
) goto exit
;
365 ret
= map_error( ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
366 serverctrlsU
, clientctrlsU
));
370 modarrayfreeU( modsU
);
371 controlarrayfreeU( serverctrlsU
);
372 controlarrayfreeU( clientctrlsU
);
378 /***********************************************************************
379 * ldap_modify_sA (WLDAP32.@)
381 * See ldap_modify_sW.
383 ULONG CDECL
ldap_modify_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
385 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
388 LDAPModW
**modsW
= NULL
;
390 ret
= WLDAP32_LDAP_NO_MEMORY
;
392 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
394 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
401 modsW
= modarrayAtoW( mods
);
402 if (!modsW
) goto exit
;
405 ret
= ldap_modify_sW( ld
, dnW
, modsW
);
409 modarrayfreeW( modsW
);
415 /***********************************************************************
416 * ldap_modify_sW (WLDAP32.@)
418 * Change an entry in a directory tree (synchronous operation).
421 * ld [I] Pointer to an LDAP context.
422 * dn [I] DN of the entry to change.
423 * attrs [I] Pointer to an array of LDAPModW structures, each
424 * specifying an attribute and its values to change.
427 * Success: LDAP_SUCCESS
428 * Failure: An LDAP error code.
430 ULONG CDECL
ldap_modify_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
432 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
435 LDAPMod
**modsU
= NULL
;
437 ret
= WLDAP32_LDAP_NO_MEMORY
;
439 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
441 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
448 modsU
= modarrayWtoU( mods
);
449 if (!modsU
) goto exit
;
452 ret
= map_error( ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, NULL
, NULL
));
456 modarrayfreeU( modsU
);