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"
35 #define LDAP_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
39 #include "winldap_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 ULONG ldap_search_abandon_page( WLDAP32_LDAP *ld, PLDAPSearch search )
46 FIXME( "(%p, %p)\n", ld, search );
52 ULONG ldap_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
53 PCHAR attrs[], ULONG attrsonly )
55 ULONG ret = LDAP_NOT_SUPPORTED;
57 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
59 ret = WLDAP32_LDAP_NO_MEMORY;
61 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_a(base),
62 scope, debugstr_a(filter), attrs, attrsonly );
67 baseW = strAtoW( base );
68 if (!baseW) goto exit;
71 filterW = strAtoW( filter );
72 if (!filterW) goto exit;
75 attrsW = strarrayAtoW( attrs );
76 if (!attrsW) goto exit;
79 ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
84 strarrayfreeW( attrsW );
90 ULONG ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
91 PWCHAR attrs[], ULONG attrsonly )
93 ULONG ret = LDAP_NOT_SUPPORTED;
95 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
98 ret = WLDAP32_LDAP_NO_MEMORY;
100 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_w(base),
101 scope, debugstr_w(filter), attrs, attrsonly );
103 if (!ld) return ~0UL;
106 baseU = strWtoU( base );
107 if (!baseU) goto exit;
110 filterU = strWtoU( filter );
111 if (!filterU) goto exit;
114 attrsU = strarrayWtoU( attrs );
115 if (!attrsU) goto exit;
118 ret = ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly,
119 NULL, NULL, NULL, 0, &msg );
121 if (ret == LDAP_SUCCESS)
129 strarrayfreeU( attrsU );
135 ULONG ldap_search_extA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
136 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
137 PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
139 ULONG ret = LDAP_NOT_SUPPORTED;
141 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
142 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
144 ret = WLDAP32_LDAP_NO_MEMORY;
146 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
147 ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
148 serverctrls, clientctrls, timelimit, sizelimit, message );
150 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
153 baseW = strAtoW( base );
154 if (!baseW) goto exit;
158 filterW = strAtoW( filter );
159 if (!filterW) goto exit;
162 attrsW = strarrayAtoW( attrs );
163 if (!attrsW) goto exit;
166 serverctrlsW = controlarrayAtoW( serverctrls );
167 if (!serverctrlsW) goto exit;
170 clientctrlsW = controlarrayAtoW( clientctrls );
171 if (!clientctrlsW) goto exit;
174 ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly,
175 serverctrlsW, clientctrlsW, timelimit, sizelimit, message );
180 strarrayfreeW( attrsW );
181 controlarrayfreeW( serverctrlsW );
182 controlarrayfreeW( clientctrlsW );
188 ULONG ldap_search_extW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
189 PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
190 PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
192 ULONG ret = LDAP_NOT_SUPPORTED;
194 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
195 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
198 ret = WLDAP32_LDAP_NO_MEMORY;
200 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
201 ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
202 serverctrls, clientctrls, timelimit, sizelimit, message );
204 if (!ld) return ~0UL;
207 baseU = strWtoU( base );
208 if (!baseU) goto exit;
211 filterU = strWtoU( filter );
212 if (!filterU) goto exit;
215 attrsU = strarrayWtoU( attrs );
216 if (!attrsU) goto exit;
219 serverctrlsU = controlarrayWtoU( serverctrls );
220 if (!serverctrlsU) goto exit;
223 clientctrlsU = controlarrayWtoU( clientctrls );
224 if (!clientctrlsU) goto exit;
227 tv.tv_sec = timelimit;
230 ret = ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly,
231 serverctrlsU, clientctrlsU, &tv, sizelimit, (int *)message );
236 strarrayfreeU( attrsU );
237 controlarrayfreeU( serverctrlsU );
238 controlarrayfreeU( clientctrlsU );
244 ULONG ldap_search_ext_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
245 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
246 PLDAPControlA *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
248 ULONG ret = LDAP_NOT_SUPPORTED;
250 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
251 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
253 ret = WLDAP32_LDAP_NO_MEMORY;
255 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, %p, 0x%08lx, %p)\n",
256 ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
257 serverctrls, clientctrls, timeout, sizelimit, res );
259 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
262 baseW = strAtoW( base );
263 if (!baseW) goto exit;
266 filterW = strAtoW( filter );
267 if (!filterW) goto exit;
270 attrsW = strarrayAtoW( attrs );
271 if (!attrsW) goto exit;
274 serverctrlsW = controlarrayAtoW( serverctrls );
275 if (!serverctrlsW) goto exit;
278 clientctrlsW = controlarrayAtoW( clientctrls );
279 if (!clientctrlsW) goto exit;
282 ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly,
283 serverctrlsW, clientctrlsW, timeout, sizelimit, res );
288 strarrayfreeW( attrsW );
289 controlarrayfreeW( serverctrlsW );
290 controlarrayfreeW( clientctrlsW );
296 ULONG ldap_search_ext_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
297 PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
298 PLDAPControlW *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
300 ULONG ret = LDAP_NOT_SUPPORTED;
302 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
303 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
305 ret = WLDAP32_LDAP_NO_MEMORY;
307 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, %p, 0x%08lx, %p)\n",
308 ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
309 serverctrls, clientctrls, timeout, sizelimit, res );
311 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
314 baseU = strWtoU( base );
315 if (!baseU) goto exit;
318 filterU = strWtoU( filter );
319 if (!filterU) goto exit;
322 attrsU = strarrayWtoU( attrs );
323 if (!attrsU) goto exit;
326 serverctrlsU = controlarrayWtoU( serverctrls );
327 if (!serverctrlsU) goto exit;
330 clientctrlsU = controlarrayWtoU( clientctrls );
331 if (!clientctrlsU) goto exit;
334 ret = ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly,
335 serverctrlsU, clientctrlsU, (struct timeval *)timeout, sizelimit, res );
340 strarrayfreeU( attrsU );
341 controlarrayfreeU( serverctrlsU );
342 controlarrayfreeU( clientctrlsU );
348 PLDAPSearch ldap_search_init_pageA( WLDAP32_LDAP *ld, PCHAR dn, ULONG scope,
349 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
350 PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyA *sortkeys )
352 FIXME( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_a(dn),
353 scope, debugstr_a(filter), attrs, attrsonly );
357 PLDAPSearch ldap_search_init_pageW( WLDAP32_LDAP *ld, PWCHAR dn, ULONG scope,
358 PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
359 PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyW *sortkeys )
361 FIXME( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_w(dn),
362 scope, debugstr_w(filter), attrs, attrsonly );
366 ULONG ldap_search_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
367 PCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
369 ULONG ret = LDAP_NOT_SUPPORTED;
371 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
373 ret = WLDAP32_LDAP_NO_MEMORY;
375 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld, debugstr_a(base),
376 scope, debugstr_a(filter), attrs, attrsonly, res );
378 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
381 baseW = strAtoW( base );
382 if (!baseW) goto exit;
385 filterW = strAtoW( filter );
386 if (!filterW) goto exit;
389 attrsW = strarrayAtoW( attrs );
390 if (!attrsW) goto exit;
393 ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
398 strarrayfreeW( attrsW );
404 ULONG ldap_search_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
405 PWCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
407 ULONG ret = LDAP_NOT_SUPPORTED;
409 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
411 ret = WLDAP32_LDAP_NO_MEMORY;
413 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld, debugstr_w(base),
414 scope, debugstr_w(filter), attrs, attrsonly, res );
416 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
419 baseU = strWtoU( base );
420 if (!baseU) goto exit;
423 filterU = strWtoU( filter );
424 if (!filterU) goto exit;
427 attrsU = strarrayWtoU( attrs );
428 if (!attrsU) goto exit;
431 ret = ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly,
432 NULL, NULL, NULL, 0, res );
437 strarrayfreeU( attrsU );
443 ULONG ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope,
444 const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
445 struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
447 ULONG ret = LDAP_NOT_SUPPORTED;
449 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
451 ret = WLDAP32_LDAP_NO_MEMORY;
453 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld,
454 debugstr_a(base), scope, debugstr_a(filter), attrs,
455 attrsonly, timeout, res );
457 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
460 baseW = strAtoW( base );
461 if (!baseW) goto exit;
464 filterW = strAtoW( filter );
465 if (!filterW) goto exit;
468 attrsW = strarrayAtoW( attrs );
469 if (!attrsW) goto exit;
472 ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
478 strarrayfreeW( attrsW );
484 ULONG ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope,
485 const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly,
486 struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
488 ULONG ret = LDAP_NOT_SUPPORTED;
490 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
492 ret = WLDAP32_LDAP_NO_MEMORY;
494 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld,
495 debugstr_w(base), scope, debugstr_w(filter), attrs,
496 attrsonly, timeout, res );
498 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
501 baseU = strWtoU( base );
502 if (!baseU) goto exit;
505 filterU = strWtoU( filter );
506 if (!filterU) goto exit;
509 attrsU = strarrayWtoU( attrs );
510 if (!attrsU) goto exit;
513 ret = ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly,
514 NULL, NULL, (struct timeval *)timeout, 0, res );
519 strarrayfreeU( attrsU );