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
*nullattrs
[] = { NULL
};
49 /***********************************************************************
50 * ldap_addA (WLDAP32.@)
54 ULONG
ldap_addA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
56 ULONG ret
= LDAP_NOT_SUPPORTED
;
59 LDAPModW
**attrsW
= NULL
;
61 ret
= WLDAP32_LDAP_NO_MEMORY
;
63 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
72 attrsW
= modarrayAtoW( attrs
);
73 if (!attrsW
) goto exit
;
76 ret
= ldap_addW( ld
, dnW
, attrsW
);
80 modarrayfreeW( attrsW
);
86 /***********************************************************************
87 * ldap_addW (WLDAP32.@)
89 * Add an entry to a directory tree (asynchronous operation).
92 * ld [I] Pointer to an LDAP context.
93 * dn [I] DN of the entry to add.
94 * attrs [I] Pointer to an array of LDAPModW structures, each
95 * specifying an attribute and its values to add.
98 * Success: Message ID of the add 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
ldap_addW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
108 ULONG ret
= LDAP_NOT_SUPPORTED
;
111 LDAPMod
**attrsU
= NULL
;
114 ret
= WLDAP32_LDAP_NO_MEMORY
;
116 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
118 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
125 attrsU
= modarrayWtoU( attrs
);
126 if (!attrsU
) goto exit
;
129 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
, &msg
);
131 if (ret
== LDAP_SUCCESS
)
138 modarrayfreeU( attrsU
);
144 /***********************************************************************
145 * ldap_add_extA (WLDAP32.@)
149 ULONG
ldap_add_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
150 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
152 ULONG ret
= LDAP_NOT_SUPPORTED
;
155 LDAPModW
**attrsW
= NULL
;
156 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
158 ret
= WLDAP32_LDAP_NO_MEMORY
;
160 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), attrs
,
161 serverctrls
, clientctrls
, message
);
163 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
170 attrsW
= modarrayAtoW( attrs
);
171 if (!attrsW
) goto exit
;
174 serverctrlsW
= controlarrayAtoW( serverctrls
);
175 if (!serverctrlsW
) goto exit
;
178 clientctrlsW
= controlarrayAtoW( clientctrls
);
179 if (!clientctrlsW
) goto exit
;
182 ret
= ldap_add_extW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
, message
);
186 modarrayfreeW( attrsW
);
187 controlarrayfreeW( serverctrlsW
);
188 controlarrayfreeW( clientctrlsW
);
194 /***********************************************************************
195 * ldap_add_extW (WLDAP32.@)
197 * Add an entry to a directory tree (asynchronous operation).
200 * ld [I] Pointer to an LDAP context.
201 * dn [I] DN of the entry to add.
202 * attrs [I] Pointer to an array of LDAPModW structures, each
203 * specifying an attribute and its values to add.
204 * serverctrls [I] Array of LDAP server controls.
205 * clientctrls [I] Array of LDAP client controls.
206 * message [O] Message ID of the add operation.
209 * Success: LDAP_SUCCESS
210 * Failure: An LDAP error code.
213 * Call ldap_result with the message ID to get the result of
214 * the operation. The serverctrls and clientctrls parameters are
215 * optional and should be set to NULL if not used.
217 ULONG
ldap_add_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
218 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
220 ULONG ret
= LDAP_NOT_SUPPORTED
;
223 LDAPMod
**attrsU
= NULL
;
224 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
227 ret
= WLDAP32_LDAP_NO_MEMORY
;
229 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), attrs
,
230 serverctrls
, clientctrls
, message
);
232 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
239 attrsU
= modarrayWtoU( attrs
);
240 if (!attrsU
) goto exit
;
243 serverctrlsU
= controlarrayWtoU( serverctrls
);
244 if (!serverctrlsU
) goto exit
;
247 clientctrlsU
= controlarrayWtoU( clientctrls
);
248 if (!clientctrlsU
) goto exit
;
251 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, serverctrlsU
,
252 clientctrlsU
, message
? (int *)message
: &dummy
);
256 modarrayfreeU( attrsU
);
257 controlarrayfreeU( serverctrlsU
);
258 controlarrayfreeU( clientctrlsU
);
264 /***********************************************************************
265 * ldap_add_ext_sA (WLDAP32.@)
267 * See ldap_add_ext_sW.
269 ULONG
ldap_add_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
270 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
272 ULONG ret
= LDAP_NOT_SUPPORTED
;
275 LDAPModW
**attrsW
= NULL
;
276 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
278 ret
= WLDAP32_LDAP_NO_MEMORY
;
280 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), attrs
,
281 serverctrls
, clientctrls
);
283 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
290 attrsW
= modarrayAtoW( attrs
);
291 if (!attrsW
) goto exit
;
294 serverctrlsW
= controlarrayAtoW( serverctrls
);
295 if (!serverctrlsW
) goto exit
;
298 clientctrlsW
= controlarrayAtoW( clientctrls
);
299 if (!clientctrlsW
) goto exit
;
302 ret
= ldap_add_ext_sW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
);
306 modarrayfreeW( attrsW
);
307 controlarrayfreeW( serverctrlsW
);
308 controlarrayfreeW( clientctrlsW
);
314 /***********************************************************************
315 * ldap_add_ext_sW (WLDAP32.@)
317 * Add an entry to a directory tree (synchronous operation).
320 * ld [I] Pointer to an LDAP context.
321 * dn [I] DN of the entry to add.
322 * attrs [I] Pointer to an array of LDAPModW structures, each
323 * specifying an attribute and its values to add.
324 * serverctrls [I] Array of LDAP server controls.
325 * clientctrls [I] Array of LDAP client controls.
328 * Success: LDAP_SUCCESS
329 * Failure: An LDAP error code.
332 * The serverctrls and clientctrls parameters are optional and
333 * should be set to NULL if not used.
335 ULONG
ldap_add_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
336 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
338 ULONG ret
= LDAP_NOT_SUPPORTED
;
341 LDAPMod
**attrsU
= NULL
;
342 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
344 ret
= WLDAP32_LDAP_NO_MEMORY
;
346 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), attrs
,
347 serverctrls
, clientctrls
);
349 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
356 attrsU
= modarrayWtoU( attrs
);
357 if (!attrsU
) goto exit
;
360 serverctrlsU
= controlarrayWtoU( serverctrls
);
361 if (!serverctrlsU
) goto exit
;
364 clientctrlsU
= controlarrayWtoU( clientctrls
);
365 if (!clientctrlsU
) goto exit
;
368 ret
= ldap_add_ext_s( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
,
369 serverctrlsU
, clientctrlsU
);
373 modarrayfreeU( attrsU
);
374 controlarrayfreeU( serverctrlsU
);
375 controlarrayfreeU( clientctrlsU
);
381 /***********************************************************************
382 * ldap_add_sA (WLDAP32.@)
386 ULONG
ldap_add_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
388 ULONG ret
= LDAP_NOT_SUPPORTED
;
391 LDAPModW
**attrsW
= NULL
;
393 ret
= WLDAP32_LDAP_NO_MEMORY
;
395 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
397 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
404 attrsW
= modarrayAtoW( attrs
);
405 if (!attrsW
) goto exit
;
408 ret
= ldap_add_sW( ld
, dnW
, attrsW
);
412 modarrayfreeW( attrsW
);
418 /***********************************************************************
419 * ldap_add_sW (WLDAP32.@)
421 * Add an entry to a directory tree (synchronous operation).
424 * ld [I] Pointer to an LDAP context.
425 * dn [I] DN of the entry to add.
426 * attrs [I] Pointer to an array of LDAPModW structures, each
427 * specifying an attribute and its values to add.
430 * Success: LDAP_SUCCESS
431 * Failure: An LDAP error code.
433 ULONG
ldap_add_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
435 ULONG ret
= LDAP_NOT_SUPPORTED
;
438 LDAPMod
**attrsU
= NULL
;
440 ret
= WLDAP32_LDAP_NO_MEMORY
;
442 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
444 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
451 attrsU
= modarrayWtoU( attrs
);
452 if (!attrsU
) goto exit
;
455 ret
= ldap_add_ext_s( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
);
459 modarrayfreeU( attrsU
);