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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
24 #include "wine/debug.h"
34 static LDAPMod
*nullattrs
[] = { NULL
};
36 #define LDAP_NOT_SUPPORTED 0x5c
39 #include "winldap_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
44 /***********************************************************************
45 * ldap_addA (WLDAP32.@)
49 ULONG
ldap_addA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
51 ULONG ret
= LDAP_NOT_SUPPORTED
;
54 LDAPModW
**attrsW
= NULL
;
56 ret
= WLDAP32_LDAP_NO_MEMORY
;
58 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
67 attrsW
= modarrayAtoW( attrs
);
68 if (!attrsW
) goto exit
;
71 ret
= ldap_addW( ld
, dnW
, attrsW
);
75 modarrayfreeW( attrsW
);
81 /***********************************************************************
82 * ldap_addW (WLDAP32.@)
84 * Add an entry to a directory tree (asynchronous operation).
87 * ld [I] Pointer to an LDAP context.
88 * dn [I] DN of the entry to add.
89 * attrs [I] Pointer to an array of LDAPModW structures, each
90 * specifying an attribute and its values to add.
93 * Success: Message ID of the add operation.
94 * Failure: An LDAP error code.
97 * Call ldap_result with the message ID to get the result of
98 * the operation. Cancel the operation by calling ldap_abandon
99 * with the message ID.
101 ULONG
ldap_addW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
103 ULONG ret
= LDAP_NOT_SUPPORTED
;
106 LDAPMod
**attrsU
= NULL
;
109 ret
= WLDAP32_LDAP_NO_MEMORY
;
111 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
113 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
120 attrsU
= modarrayWtoU( attrs
);
121 if (!attrsU
) goto exit
;
124 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
, &msg
);
126 if (ret
== LDAP_SUCCESS
)
133 modarrayfreeU( attrsU
);
139 /***********************************************************************
140 * ldap_add_extA (WLDAP32.@)
144 ULONG
ldap_add_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
145 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
147 ULONG ret
= LDAP_NOT_SUPPORTED
;
150 LDAPModW
**attrsW
= 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
), attrs
,
156 serverctrls
, clientctrls
, message
);
158 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
165 attrsW
= modarrayAtoW( attrs
);
166 if (!attrsW
) goto exit
;
169 serverctrlsW
= controlarrayAtoW( serverctrls
);
170 if (!serverctrlsW
) goto exit
;
173 clientctrlsW
= controlarrayAtoW( clientctrls
);
174 if (!clientctrlsW
) goto exit
;
177 ret
= ldap_add_extW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
, message
);
181 modarrayfreeW( attrsW
);
182 controlarrayfreeW( serverctrlsW
);
183 controlarrayfreeW( clientctrlsW
);
189 /***********************************************************************
190 * ldap_add_extW (WLDAP32.@)
192 * Add an entry to a directory tree (asynchronous operation).
195 * ld [I] Pointer to an LDAP context.
196 * dn [I] DN of the entry to add.
197 * attrs [I] Pointer to an array of LDAPModW structures, each
198 * specifying an attribute and its values to add.
199 * serverctrls [I] Array of LDAP server controls.
200 * clientctrls [I] Array of LDAP client controls.
201 * message [O] Message ID of the add 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
ldap_add_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
213 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
215 ULONG ret
= LDAP_NOT_SUPPORTED
;
218 LDAPMod
**attrsU
= 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
), attrs
,
225 serverctrls
, clientctrls
, message
);
227 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
234 attrsU
= modarrayWtoU( attrs
);
235 if (!attrsU
) goto exit
;
238 serverctrlsU
= controlarrayWtoU( serverctrls
);
239 if (!serverctrlsU
) goto exit
;
242 clientctrlsU
= controlarrayWtoU( clientctrls
);
243 if (!clientctrlsU
) goto exit
;
246 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, serverctrlsU
,
247 clientctrlsU
, message
? (int *)message
: &dummy
);
251 modarrayfreeU( attrsU
);
252 controlarrayfreeU( serverctrlsU
);
253 controlarrayfreeU( clientctrlsU
);
259 /***********************************************************************
260 * ldap_add_ext_sA (WLDAP32.@)
262 * See ldap_add_ext_sW.
264 ULONG
ldap_add_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
265 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
267 ULONG ret
= LDAP_NOT_SUPPORTED
;
270 LDAPModW
**attrsW
= 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
), attrs
,
276 serverctrls
, clientctrls
);
278 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
285 attrsW
= modarrayAtoW( attrs
);
286 if (!attrsW
) goto exit
;
289 serverctrlsW
= controlarrayAtoW( serverctrls
);
290 if (!serverctrlsW
) goto exit
;
293 clientctrlsW
= controlarrayAtoW( clientctrls
);
294 if (!clientctrlsW
) goto exit
;
297 ret
= ldap_add_ext_sW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
);
301 modarrayfreeW( attrsW
);
302 controlarrayfreeW( serverctrlsW
);
303 controlarrayfreeW( clientctrlsW
);
309 /***********************************************************************
310 * ldap_add_ext_sW (WLDAP32.@)
312 * Add an entry to a directory tree (synchronous operation).
315 * ld [I] Pointer to an LDAP context.
316 * dn [I] DN of the entry to add.
317 * attrs [I] Pointer to an array of LDAPModW structures, each
318 * specifying an attribute and its values to add.
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
ldap_add_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
331 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
333 ULONG ret
= LDAP_NOT_SUPPORTED
;
336 LDAPMod
**attrsU
= 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
), attrs
,
342 serverctrls
, clientctrls
);
344 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
345 if (!attrs
) return LDAP_PROTOCOL_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
ldap_add_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
384 ULONG ret
= 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
ldap_add_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
431 ULONG ret
= 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
);