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"
38 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
40 static LDAPMod
*nullattrs
[] = { NULL
};
43 /***********************************************************************
44 * ldap_addA (WLDAP32.@)
48 ULONG CDECL
ldap_addA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
50 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
53 LDAPModW
**attrsW
= NULL
;
55 ret
= WLDAP32_LDAP_NO_MEMORY
;
57 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
66 attrsW
= modarrayAtoW( attrs
);
67 if (!attrsW
) goto exit
;
70 ret
= ldap_addW( ld
, dnW
, attrsW
);
74 modarrayfreeW( attrsW
);
80 /***********************************************************************
81 * ldap_addW (WLDAP32.@)
83 * Add an entry to a directory tree (asynchronous operation).
86 * ld [I] Pointer to an LDAP context.
87 * dn [I] DN of the entry to add.
88 * attrs [I] Pointer to an array of LDAPModW structures, each
89 * specifying an attribute and its values to add.
92 * Success: Message ID of the add 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_addW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
102 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
105 LDAPMod
**attrsU
= NULL
;
108 ret
= WLDAP32_LDAP_NO_MEMORY
;
110 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
112 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
119 attrsU
= modarrayWtoU( attrs
);
120 if (!attrsU
) goto exit
;
123 ret
= ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
, &msg
);
125 if (ret
== LDAP_SUCCESS
)
132 modarrayfreeU( attrsU
);
138 /***********************************************************************
139 * ldap_add_extA (WLDAP32.@)
143 ULONG CDECL
ldap_add_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
144 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
146 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
149 LDAPModW
**attrsW
= NULL
;
150 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
152 ret
= WLDAP32_LDAP_NO_MEMORY
;
154 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), attrs
,
155 serverctrls
, clientctrls
, message
);
157 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
164 attrsW
= modarrayAtoW( attrs
);
165 if (!attrsW
) goto exit
;
168 serverctrlsW
= controlarrayAtoW( serverctrls
);
169 if (!serverctrlsW
) goto exit
;
172 clientctrlsW
= controlarrayAtoW( clientctrls
);
173 if (!clientctrlsW
) goto exit
;
176 ret
= ldap_add_extW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
, message
);
180 modarrayfreeW( attrsW
);
181 controlarrayfreeW( serverctrlsW
);
182 controlarrayfreeW( clientctrlsW
);
188 /***********************************************************************
189 * ldap_add_extW (WLDAP32.@)
191 * Add an entry to a directory tree (asynchronous operation).
194 * ld [I] Pointer to an LDAP context.
195 * dn [I] DN of the entry to add.
196 * attrs [I] Pointer to an array of LDAPModW structures, each
197 * specifying an attribute and its values to add.
198 * serverctrls [I] Array of LDAP server controls.
199 * clientctrls [I] Array of LDAP client controls.
200 * message [O] Message ID of the add operation.
203 * Success: LDAP_SUCCESS
204 * Failure: An LDAP error code.
207 * Call ldap_result with the message ID to get the result of
208 * the operation. The serverctrls and clientctrls parameters are
209 * optional and should be set to NULL if not used.
211 ULONG CDECL
ldap_add_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
212 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
214 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
217 LDAPMod
**attrsU
= NULL
;
218 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
221 ret
= WLDAP32_LDAP_NO_MEMORY
;
223 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), attrs
,
224 serverctrls
, clientctrls
, message
);
226 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
233 attrsU
= modarrayWtoU( attrs
);
234 if (!attrsU
) goto exit
;
237 serverctrlsU
= controlarrayWtoU( serverctrls
);
238 if (!serverctrlsU
) goto exit
;
241 clientctrlsU
= controlarrayWtoU( clientctrls
);
242 if (!clientctrlsU
) goto exit
;
245 ret
= map_error( ldap_add_ext( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, serverctrlsU
,
246 clientctrlsU
, message
? (int *)message
: &dummy
));
250 modarrayfreeU( attrsU
);
251 controlarrayfreeU( serverctrlsU
);
252 controlarrayfreeU( clientctrlsU
);
258 /***********************************************************************
259 * ldap_add_ext_sA (WLDAP32.@)
261 * See ldap_add_ext_sW.
263 ULONG CDECL
ldap_add_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[],
264 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
266 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
269 LDAPModW
**attrsW
= NULL
;
270 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
272 ret
= WLDAP32_LDAP_NO_MEMORY
;
274 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), attrs
,
275 serverctrls
, clientctrls
);
277 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
284 attrsW
= modarrayAtoW( attrs
);
285 if (!attrsW
) goto exit
;
288 serverctrlsW
= controlarrayAtoW( serverctrls
);
289 if (!serverctrlsW
) goto exit
;
292 clientctrlsW
= controlarrayAtoW( clientctrls
);
293 if (!clientctrlsW
) goto exit
;
296 ret
= ldap_add_ext_sW( ld
, dnW
, attrsW
, serverctrlsW
, clientctrlsW
);
300 modarrayfreeW( attrsW
);
301 controlarrayfreeW( serverctrlsW
);
302 controlarrayfreeW( clientctrlsW
);
308 /***********************************************************************
309 * ldap_add_ext_sW (WLDAP32.@)
311 * Add an entry to a directory tree (synchronous operation).
314 * ld [I] Pointer to an LDAP context.
315 * dn [I] DN of the entry to add.
316 * attrs [I] Pointer to an array of LDAPModW structures, each
317 * specifying an attribute and its values to add.
318 * serverctrls [I] Array of LDAP server controls.
319 * clientctrls [I] Array of LDAP client controls.
322 * Success: LDAP_SUCCESS
323 * Failure: An LDAP error code.
326 * The serverctrls and clientctrls parameters are optional and
327 * should be set to NULL if not used.
329 ULONG CDECL
ldap_add_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[],
330 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
332 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
335 LDAPMod
**attrsU
= NULL
;
336 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
338 ret
= WLDAP32_LDAP_NO_MEMORY
;
340 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), attrs
,
341 serverctrls
, clientctrls
);
343 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
350 attrsU
= modarrayWtoU( attrs
);
351 if (!attrsU
) goto exit
;
354 serverctrlsU
= controlarrayWtoU( serverctrls
);
355 if (!serverctrlsU
) goto exit
;
358 clientctrlsU
= controlarrayWtoU( clientctrls
);
359 if (!clientctrlsU
) goto exit
;
362 ret
= map_error( ldap_add_ext_s( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
,
363 serverctrlsU
, clientctrlsU
));
367 modarrayfreeU( attrsU
);
368 controlarrayfreeU( serverctrlsU
);
369 controlarrayfreeU( clientctrlsU
);
375 /***********************************************************************
376 * ldap_add_sA (WLDAP32.@)
380 ULONG CDECL
ldap_add_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*attrs
[] )
382 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
385 LDAPModW
**attrsW
= NULL
;
387 ret
= WLDAP32_LDAP_NO_MEMORY
;
389 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), attrs
);
391 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
398 attrsW
= modarrayAtoW( attrs
);
399 if (!attrsW
) goto exit
;
402 ret
= ldap_add_sW( ld
, dnW
, attrsW
);
406 modarrayfreeW( attrsW
);
412 /***********************************************************************
413 * ldap_add_sW (WLDAP32.@)
415 * Add an entry to a directory tree (synchronous operation).
418 * ld [I] Pointer to an LDAP context.
419 * dn [I] DN of the entry to add.
420 * attrs [I] Pointer to an array of LDAPModW structures, each
421 * specifying an attribute and its values to add.
424 * Success: LDAP_SUCCESS
425 * Failure: An LDAP error code.
427 ULONG CDECL
ldap_add_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*attrs
[] )
429 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
432 LDAPMod
**attrsU
= NULL
;
434 ret
= WLDAP32_LDAP_NO_MEMORY
;
436 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), attrs
);
438 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
445 attrsU
= modarrayWtoU( attrs
);
446 if (!attrsU
) goto exit
;
449 ret
= map_error( ldap_add_ext_s( ld
, dn
? dnU
: "", attrs
? attrsU
: nullattrs
, NULL
, NULL
));
453 modarrayfreeU( attrsU
);