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
*nullattrs
[] = { NULL
};
45 /***********************************************************************
46 * ldap_addA (WLDAP32.@)
50 ULONG CDECL
ldap_addA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
52 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
55 LDAPModW
**attrsW
= NULL
;
57 ret
= WLDAP32_LDAP_NO_MEMORY
;
59 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
68 attrsW
= modarrayAtoW( attrs
);
69 if (!attrsW
) goto exit
;
72 ret
= ldap_addW( ld
, dnW
, attrsW
);
76 modarrayfreeW( attrsW
);
82 /***********************************************************************
83 * ldap_addW (WLDAP32.@)
85 * Add an entry to a directory tree (asynchronous operation).
88 * ld [I] Pointer to an LDAP context.
89 * dn [I] DN of the entry to add.
90 * attrs [I] Pointer to an array of LDAPModW structures, each
91 * specifying an attribute and its values to add.
94 * Success: Message ID of the add 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_addW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
104 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
107 LDAPMod
**attrsU
= NULL
;
110 ret
= WLDAP32_LDAP_NO_MEMORY
;
112 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
114 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
121 attrsU
= modarrayWtoU( attrs
);
122 if (!attrsU
) goto exit
;
125 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
, &msg
);
127 if (ret
== LDAP_SUCCESS
)
134 modarrayfreeU( attrsU
);
140 /***********************************************************************
141 * ldap_add_extA (WLDAP32.@)
145 ULONG CDECL
ldap_add_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
146 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
148 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
151 LDAPModW
**attrsW
= NULL
;
152 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
154 ret
= WLDAP32_LDAP_NO_MEMORY
;
156 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), attrs
,
157 serverctrls
, clientctrls
, message
);
159 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
166 attrsW
= modarrayAtoW( attrs
);
167 if (!attrsW
) goto exit
;
170 serverctrlsW
= controlarrayAtoW( serverctrls
);
171 if (!serverctrlsW
) goto exit
;
174 clientctrlsW
= controlarrayAtoW( clientctrls
);
175 if (!clientctrlsW
) goto exit
;
178 ret
= ldap_add_extW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
, message
);
182 modarrayfreeW( attrsW
);
183 controlarrayfreeW( serverctrlsW
);
184 controlarrayfreeW( clientctrlsW
);
190 /***********************************************************************
191 * ldap_add_extW (WLDAP32.@)
193 * Add an entry to a directory tree (asynchronous operation).
196 * ld [I] Pointer to an LDAP context.
197 * dn [I] DN of the entry to add.
198 * attrs [I] Pointer to an array of LDAPModW structures, each
199 * specifying an attribute and its values to add.
200 * serverctrls [I] Array of LDAP server controls.
201 * clientctrls [I] Array of LDAP client controls.
202 * message [O] Message ID of the add operation.
205 * Success: LDAP_SUCCESS
206 * Failure: An LDAP error code.
209 * Call ldap_result with the message ID to get the result of
210 * the operation. The serverctrls and clientctrls parameters are
211 * optional and should be set to NULL if not used.
213 ULONG CDECL
ldap_add_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
214 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
216 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
219 LDAPMod
**attrsU
= NULL
;
220 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
223 ret
= WLDAP32_LDAP_NO_MEMORY
;
225 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), attrs
,
226 serverctrls
, clientctrls
, message
);
228 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
235 attrsU
= modarrayWtoU( attrs
);
236 if (!attrsU
) goto exit
;
239 serverctrlsU
= controlarrayWtoU( serverctrls
);
240 if (!serverctrlsU
) goto exit
;
243 clientctrlsU
= controlarrayWtoU( clientctrls
);
244 if (!clientctrlsU
) goto exit
;
247 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, serverctrlsU
,
248 clientctrlsU
, message
? (int *)message
: &dummy
);
252 modarrayfreeU( attrsU
);
253 controlarrayfreeU( serverctrlsU
);
254 controlarrayfreeU( clientctrlsU
);
260 /***********************************************************************
261 * ldap_add_ext_sA (WLDAP32.@)
263 * See ldap_add_ext_sW.
265 ULONG CDECL
ldap_add_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
266 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
268 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
271 LDAPModW
**attrsW
= NULL
;
272 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
274 ret
= WLDAP32_LDAP_NO_MEMORY
;
276 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), attrs
,
277 serverctrls
, clientctrls
);
279 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
286 attrsW
= modarrayAtoW( attrs
);
287 if (!attrsW
) goto exit
;
290 serverctrlsW
= controlarrayAtoW( serverctrls
);
291 if (!serverctrlsW
) goto exit
;
294 clientctrlsW
= controlarrayAtoW( clientctrls
);
295 if (!clientctrlsW
) goto exit
;
298 ret
= ldap_add_ext_sW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
);
302 modarrayfreeW( attrsW
);
303 controlarrayfreeW( serverctrlsW
);
304 controlarrayfreeW( clientctrlsW
);
310 /***********************************************************************
311 * ldap_add_ext_sW (WLDAP32.@)
313 * Add an entry to a directory tree (synchronous operation).
316 * ld [I] Pointer to an LDAP context.
317 * dn [I] DN of the entry to add.
318 * attrs [I] Pointer to an array of LDAPModW structures, each
319 * specifying an attribute and its values to add.
320 * serverctrls [I] Array of LDAP server controls.
321 * clientctrls [I] Array of LDAP client controls.
324 * Success: LDAP_SUCCESS
325 * Failure: An LDAP error code.
328 * The serverctrls and clientctrls parameters are optional and
329 * should be set to NULL if not used.
331 ULONG CDECL
ldap_add_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
332 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
334 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
337 LDAPMod
**attrsU
= NULL
;
338 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
340 ret
= WLDAP32_LDAP_NO_MEMORY
;
342 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), attrs
,
343 serverctrls
, clientctrls
);
345 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
352 attrsU
= modarrayWtoU( attrs
);
353 if (!attrsU
) goto exit
;
356 serverctrlsU
= controlarrayWtoU( serverctrls
);
357 if (!serverctrlsU
) goto exit
;
360 clientctrlsU
= controlarrayWtoU( clientctrls
);
361 if (!clientctrlsU
) goto exit
;
364 ret
= ldap_add_ext_s( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
,
365 serverctrlsU
, clientctrlsU
);
369 modarrayfreeU( attrsU
);
370 controlarrayfreeU( serverctrlsU
);
371 controlarrayfreeU( clientctrlsU
);
377 /***********************************************************************
378 * ldap_add_sA (WLDAP32.@)
382 ULONG CDECL
ldap_add_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
384 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
387 LDAPModW
**attrsW
= NULL
;
389 ret
= WLDAP32_LDAP_NO_MEMORY
;
391 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
393 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
400 attrsW
= modarrayAtoW( attrs
);
401 if (!attrsW
) goto exit
;
404 ret
= ldap_add_sW( ld
, dnW
, attrsW
);
408 modarrayfreeW( attrsW
);
414 /***********************************************************************
415 * ldap_add_sW (WLDAP32.@)
417 * Add an entry to a directory tree (synchronous operation).
420 * ld [I] Pointer to an LDAP context.
421 * dn [I] DN of the entry to add.
422 * attrs [I] Pointer to an array of LDAPModW structures, each
423 * specifying an attribute and its values to add.
426 * Success: LDAP_SUCCESS
427 * Failure: An LDAP error code.
429 ULONG CDECL
ldap_add_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
431 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
434 LDAPMod
**attrsU
= NULL
;
436 ret
= WLDAP32_LDAP_NO_MEMORY
;
438 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
440 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
447 attrsU
= modarrayWtoU( attrs
);
448 if (!attrsU
) goto exit
;
451 ret
= ldap_add_ext_s( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
);
455 modarrayfreeU( attrsU
);