Stub implementations for functions handling paged search results.
[wine/wine64.git] / dlls / wldap32 / search.c
blobbab580c88d278714643c05ba15538fb005db0db7
1 /*
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
21 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
37 #endif
39 #include "winldap_private.h"
40 #include "wldap32.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 );
48 if (!ld) return ~0UL;
49 return LDAP_SUCCESS;
52 ULONG ldap_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
53 PCHAR attrs[], ULONG attrsonly )
55 ULONG ret = LDAP_NOT_SUPPORTED;
56 #ifdef HAVE_LDAP
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 );
64 if (!ld) return ~0UL;
66 if (base) {
67 baseW = strAtoW( base );
68 if (!baseW) goto exit;
70 if (filter) {
71 filterW = strAtoW( filter );
72 if (!filterW) goto exit;
74 if (attrs) {
75 attrsW = strarrayAtoW( attrs );
76 if (!attrsW) goto exit;
79 ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
81 exit:
82 strfreeW( baseW );
83 strfreeW( filterW );
84 strarrayfreeW( attrsW );
86 #endif
87 return ret;
90 ULONG ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
91 PWCHAR attrs[], ULONG attrsonly )
93 ULONG ret = LDAP_NOT_SUPPORTED;
94 #ifdef HAVE_LDAP
95 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
96 int msg;
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;
105 if (base) {
106 baseU = strWtoU( base );
107 if (!baseU) goto exit;
109 if (filter) {
110 filterU = strWtoU( filter );
111 if (!filterU) goto exit;
113 if (attrs) {
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)
122 ret = msg;
123 else
124 ret = ~0UL;
126 exit:
127 strfreeU( baseU );
128 strfreeU( filterU );
129 strarrayfreeU( attrsU );
131 #endif
132 return ret;
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;
140 #ifdef HAVE_LDAP
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;
152 if (base) {
153 baseW = strAtoW( base );
154 if (!baseW) goto exit;
156 if (filter)
158 filterW = strAtoW( filter );
159 if (!filterW) goto exit;
161 if (attrs) {
162 attrsW = strarrayAtoW( attrs );
163 if (!attrsW) goto exit;
165 if (serverctrls) {
166 serverctrlsW = controlarrayAtoW( serverctrls );
167 if (!serverctrlsW) goto exit;
169 if (clientctrls) {
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 );
177 exit:
178 strfreeW( baseW );
179 strfreeW( filterW );
180 strarrayfreeW( attrsW );
181 controlarrayfreeW( serverctrlsW );
182 controlarrayfreeW( clientctrlsW );
184 #endif
185 return ret;
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;
193 #ifdef HAVE_LDAP
194 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
195 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
196 struct timeval tv;
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;
206 if (base) {
207 baseU = strWtoU( base );
208 if (!baseU) goto exit;
210 if (filter) {
211 filterU = strWtoU( filter );
212 if (!filterU) goto exit;
214 if (attrs) {
215 attrsU = strarrayWtoU( attrs );
216 if (!attrsU) goto exit;
218 if (serverctrls) {
219 serverctrlsU = controlarrayWtoU( serverctrls );
220 if (!serverctrlsU) goto exit;
222 if (clientctrls) {
223 clientctrlsU = controlarrayWtoU( clientctrls );
224 if (!clientctrlsU) goto exit;
227 tv.tv_sec = timelimit;
228 tv.tv_usec = 0;
230 ret = ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly,
231 serverctrlsU, clientctrlsU, &tv, sizelimit, (int *)message );
233 exit:
234 strfreeU( baseU );
235 strfreeU( filterU );
236 strarrayfreeU( attrsU );
237 controlarrayfreeU( serverctrlsU );
238 controlarrayfreeU( clientctrlsU );
240 #endif
241 return ret;
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;
249 #ifdef HAVE_LDAP
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;
261 if (base) {
262 baseW = strAtoW( base );
263 if (!baseW) goto exit;
265 if (filter) {
266 filterW = strAtoW( filter );
267 if (!filterW) goto exit;
269 if (attrs) {
270 attrsW = strarrayAtoW( attrs );
271 if (!attrsW) goto exit;
273 if (serverctrls) {
274 serverctrlsW = controlarrayAtoW( serverctrls );
275 if (!serverctrlsW) goto exit;
277 if (clientctrls) {
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 );
285 exit:
286 strfreeW( baseW );
287 strfreeW( filterW );
288 strarrayfreeW( attrsW );
289 controlarrayfreeW( serverctrlsW );
290 controlarrayfreeW( clientctrlsW );
292 #endif
293 return ret;
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;
301 #ifdef HAVE_LDAP
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;
313 if (base) {
314 baseU = strWtoU( base );
315 if (!baseU) goto exit;
317 if (filter) {
318 filterU = strWtoU( filter );
319 if (!filterU) goto exit;
321 if (attrs) {
322 attrsU = strarrayWtoU( attrs );
323 if (!attrsU) goto exit;
325 if (serverctrls) {
326 serverctrlsU = controlarrayWtoU( serverctrls );
327 if (!serverctrlsU) goto exit;
329 if (clientctrls) {
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 );
337 exit:
338 strfreeU( baseU );
339 strfreeU( filterU );
340 strarrayfreeU( attrsU );
341 controlarrayfreeU( serverctrlsU );
342 controlarrayfreeU( clientctrlsU );
344 #endif
345 return ret;
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 );
354 return NULL;
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 );
363 return NULL;
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;
370 #ifdef HAVE_LDAP
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;
380 if (base) {
381 baseW = strAtoW( base );
382 if (!baseW) goto exit;
384 if (filter) {
385 filterW = strAtoW( filter );
386 if (!filterW) goto exit;
388 if (attrs) {
389 attrsW = strarrayAtoW( attrs );
390 if (!attrsW) goto exit;
393 ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
395 exit:
396 strfreeW( baseW );
397 strfreeW( filterW );
398 strarrayfreeW( attrsW );
400 #endif
401 return ret;
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;
408 #ifdef HAVE_LDAP
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;
418 if (base) {
419 baseU = strWtoU( base );
420 if (!baseU) goto exit;
422 if (filter) {
423 filterU = strWtoU( filter );
424 if (!filterU) goto exit;
426 if (attrs) {
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 );
434 exit:
435 strfreeU( baseU );
436 strfreeU( filterU );
437 strarrayfreeU( attrsU );
439 #endif
440 return ret;
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;
448 #ifdef HAVE_LDAP
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;
459 if (base) {
460 baseW = strAtoW( base );
461 if (!baseW) goto exit;
463 if (filter) {
464 filterW = strAtoW( filter );
465 if (!filterW) goto exit;
467 if (attrs) {
468 attrsW = strarrayAtoW( attrs );
469 if (!attrsW) goto exit;
472 ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
473 timeout, res );
475 exit:
476 strfreeW( baseW );
477 strfreeW( filterW );
478 strarrayfreeW( attrsW );
480 #endif
481 return ret;
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;
489 #ifdef HAVE_LDAP
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;
500 if (base) {
501 baseU = strWtoU( base );
502 if (!baseU) goto exit;
504 if (filter) {
505 filterU = strWtoU( filter );
506 if (!filterU) goto exit;
508 if (attrs) {
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 );
516 exit:
517 strfreeU( baseU );
518 strfreeU( filterU );
519 strarrayfreeU( attrsU );
521 #endif
522 return ret;