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"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
39 /***********************************************************************
40 * ldap_compareA (WLDAP32.@)
44 ULONG CDECL ldap_compareA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value )
46 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
48 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
52 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(attr),
55 if (!ld || !attr) return ~0u;
62 attrW = strAtoW( attr );
63 if (!attrW) goto exit;
66 valueW = strAtoW( value );
67 if (!valueW) goto exit;
70 ret = ldap_compareW( ld, dnW, attrW, valueW );
81 /***********************************************************************
82 * ldap_compareW (WLDAP32.@)
84 * Check if an attribute has a certain value (asynchronous operation).
87 * ld [I] Pointer to an LDAP context.
88 * dn [I] DN of entry to compare value for.
89 * attr [I] Attribute to compare value for.
90 * value [I] Value to compare.
93 * Success: Message ID of the compare operation.
94 * Failure: An LDAP error code.
96 ULONG CDECL ldap_compareW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value )
98 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
100 char *dnU = NULL, *attrU = NULL, *valueU = NULL;
101 struct berval val = { 0, NULL };
106 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(attr),
109 if (!ld || !attr) return ~0u;
116 attrU = strWtoU( attr );
117 if (!attrU) goto exit;
120 valueU = strWtoU( value );
121 if (!valueU) goto exit;
123 val.bv_len = strlen( valueU );
127 ret = ldap_compare_ext( ld, dn ? dnU : "", attrU, &val, NULL, NULL, &msg );
129 if (ret == LDAP_SUCCESS)
143 /***********************************************************************
144 * ldap_compare_extA (WLDAP32.@)
146 * See ldap_compare_extW.
148 ULONG CDECL ldap_compare_extA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value,
149 struct WLDAP32_berval *data, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls,
152 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
154 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
155 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
157 ret = WLDAP32_LDAP_NO_MEMORY;
159 TRACE( "(%p, %s, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
160 debugstr_a(attr), debugstr_a(value), data, serverctrls,
161 clientctrls, message );
163 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
170 attrW = strAtoW( attr );
171 if (!attrW) goto exit;
174 valueW = strAtoW( value );
175 if (!valueW) goto exit;
178 serverctrlsW = controlarrayAtoW( serverctrls );
179 if (!serverctrlsW) goto exit;
182 clientctrlsW = controlarrayAtoW( clientctrls );
183 if (!clientctrlsW) goto exit;
186 ret = ldap_compare_extW( ld, dnW, attrW, valueW, data,
187 serverctrlsW, clientctrlsW, message );
193 controlarrayfreeW( serverctrlsW );
194 controlarrayfreeW( clientctrlsW );
200 /***********************************************************************
201 * ldap_compare_extW (WLDAP32.@)
203 * Check if an attribute has a certain value (asynchronous operation).
206 * ld [I] Pointer to an LDAP context.
207 * dn [I] DN of entry to compare value for.
208 * attr [I] Attribute to compare value for.
209 * value [I] string encoded value to compare.
210 * data [I] berval encoded value to compare.
211 * serverctrls [I] Array of LDAP server controls.
212 * clientctrls [I] Array of LDAP client controls.
213 * message [O] Message ID of the compare operation.
216 * Success: LDAP_SUCCESS
217 * Failure: An LDAP error code.
220 * Set value to compare strings or data to compare binary values. If
221 * both are non-NULL, data will be used. The serverctrls and clientctrls
222 * parameters are optional and should be set to NULL if not used.
224 ULONG CDECL ldap_compare_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value,
225 struct WLDAP32_berval *data, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls,
228 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
230 char *dnU = NULL, *attrU = NULL, *valueU = NULL;
231 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
232 struct berval val = { 0, NULL };
234 ret = WLDAP32_LDAP_NO_MEMORY;
236 TRACE( "(%p, %s, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
237 debugstr_w(attr), debugstr_w(value), data, serverctrls,
238 clientctrls, message );
240 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
241 if (!attr) return WLDAP32_LDAP_NO_MEMORY;
248 attrU = strWtoU( attr );
249 if (!attrU) goto exit;
253 valueU = strWtoU( value );
254 if (!valueU) goto exit;
256 val.bv_len = strlen( valueU );
261 serverctrlsU = controlarrayWtoU( serverctrls );
262 if (!serverctrlsU) goto exit;
265 clientctrlsU = controlarrayWtoU( clientctrls );
266 if (!clientctrlsU) goto exit;
269 ret = map_error( ldap_compare_ext( ld, dn ? dnU : "", attrU, data ? (struct berval *)data : &val,
270 serverctrlsU, clientctrlsU, (int *)message ));
276 controlarrayfreeU( serverctrlsU );
277 controlarrayfreeU( clientctrlsU );
283 /***********************************************************************
284 * ldap_compare_ext_sA (WLDAP32.@)
286 * See ldap_compare_ext_sW.
288 ULONG CDECL ldap_compare_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value,
289 struct WLDAP32_berval *data, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
291 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
293 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
294 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
296 ret = WLDAP32_LDAP_NO_MEMORY;
298 TRACE( "(%p, %s, %s, %s, %p, %p, %p)\n", ld, debugstr_a(dn),
299 debugstr_a(attr), debugstr_a(value), data, serverctrls,
302 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
309 attrW = strAtoW( attr );
310 if (!attrW) goto exit;
313 valueW = strAtoW( value );
314 if (!valueW) goto exit;
317 serverctrlsW = controlarrayAtoW( serverctrls );
318 if (!serverctrlsW) goto exit;
321 clientctrlsW = controlarrayAtoW( clientctrls );
322 if (!clientctrlsW) goto exit;
325 ret = ldap_compare_ext_sW( ld, dnW, attrW, valueW, data, serverctrlsW,
332 controlarrayfreeW( serverctrlsW );
333 controlarrayfreeW( clientctrlsW );
339 /***********************************************************************
340 * ldap_compare_ext_sW (WLDAP32.@)
342 * Check if an attribute has a certain value (synchronous operation).
345 * ld [I] Pointer to an LDAP context.
346 * dn [I] DN of entry to compare value for.
347 * attr [I] Attribute to compare value for.
348 * value [I] string encoded value to compare.
349 * data [I] berval encoded value to compare.
350 * serverctrls [I] Array of LDAP server controls.
351 * clientctrls [I] Array of LDAP client controls.
354 * Success: LDAP_SUCCESS
355 * Failure: An LDAP error code.
358 * Set value to compare strings or data to compare binary values. If
359 * both are non-NULL, data will be used. The serverctrls and clientctrls
360 * parameters are optional and should be set to NULL if not used.
362 ULONG CDECL ldap_compare_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value,
363 struct WLDAP32_berval *data, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
365 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
367 char *dnU = NULL, *attrU = NULL, *valueU = NULL;
368 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
369 struct berval val = { 0, NULL };
371 ret = WLDAP32_LDAP_NO_MEMORY;
373 TRACE( "(%p, %s, %s, %s, %p, %p, %p)\n", ld, debugstr_w(dn),
374 debugstr_w(attr), debugstr_w(value), data, serverctrls,
377 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
384 attrU = strWtoU( attr );
385 if (!attrU) goto exit;
389 valueU = strWtoU( value );
390 if (!valueU) goto exit;
392 val.bv_len = strlen( valueU );
397 serverctrlsU = controlarrayWtoU( serverctrls );
398 if (!serverctrlsU) goto exit;
401 clientctrlsU = controlarrayWtoU( clientctrls );
402 if (!clientctrlsU) goto exit;
405 ret = map_error( ldap_compare_ext_s( ld, dn ? dnU : "", attr ? attrU : "",
406 data ? (struct berval *)data : &val,
407 serverctrlsU, clientctrlsU ));
413 controlarrayfreeU( serverctrlsU );
414 controlarrayfreeU( clientctrlsU );
420 /***********************************************************************
421 * ldap_compare_sA (WLDAP32.@)
423 * See ldap_compare_sW.
425 ULONG CDECL ldap_compare_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value )
427 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
429 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
431 ret = WLDAP32_LDAP_NO_MEMORY;
433 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(attr),
436 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
443 attrW = strAtoW( attr );
444 if (!attrW) goto exit;
447 valueW = strAtoW( value );
448 if (!valueW) goto exit;
451 ret = ldap_compare_sW( ld, dnW, attrW, valueW );
462 /***********************************************************************
463 * ldap_compare_sW (WLDAP32.@)
465 * Check if an attribute has a certain value (synchronous operation).
468 * ld [I] Pointer to an LDAP context.
469 * dn [I] DN of entry to compare value for.
470 * attr [I] Attribute to compare value for.
471 * value [I] Value to compare.
474 * Success: LDAP_SUCCESS
475 * Failure: An LDAP error code.
477 ULONG CDECL ldap_compare_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value )
479 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
481 char *dnU = NULL, *attrU = NULL, *valueU = NULL;
482 struct berval val = { 0, NULL };
484 ret = WLDAP32_LDAP_NO_MEMORY;
486 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(attr),
489 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
496 attrU = strWtoU( attr );
497 if (!attrU) goto exit;
500 valueU = strWtoU( value );
501 if (!valueU) goto exit;
503 val.bv_len = strlen( valueU );
507 ret = map_error( ldap_compare_ext_s( ld, dn ? dnU : "", attr ? attrU : "", &val, NULL, NULL ));