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_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
45 PCHAR attrs[], ULONG attrsonly )
47 ULONG ret = LDAP_NOT_SUPPORTED;
49 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
51 ret = WLDAP32_LDAP_NO_MEMORY;
53 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_a(base),
54 scope, debugstr_a(filter), attrs, attrsonly );
59 baseW = strAtoW( base );
60 if (!baseW) goto exit;
63 filterW = strAtoW( filter );
64 if (!filterW) goto exit;
67 attrsW = strarrayAtoW( attrs );
68 if (!attrsW) goto exit;
71 ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
76 strarrayfreeW( attrsW );
82 ULONG ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
83 PWCHAR attrs[], ULONG attrsonly )
85 ULONG ret = LDAP_NOT_SUPPORTED;
87 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
90 ret = WLDAP32_LDAP_NO_MEMORY;
92 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_w(base),
93 scope, debugstr_w(filter), attrs, attrsonly );
98 baseU = strWtoU( base );
99 if (!baseU) goto exit;
102 filterU = strWtoU( filter );
103 if (!filterU) goto exit;
106 attrsU = strarrayWtoU( attrs );
107 if (!attrsU) goto exit;
110 ret = ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly,
111 NULL, NULL, NULL, 0, &msg );
113 if (ret == LDAP_SUCCESS)
121 strarrayfreeU( attrsU );
127 ULONG ldap_search_extA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
128 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
129 PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
131 ULONG ret = LDAP_NOT_SUPPORTED;
133 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
134 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
136 ret = WLDAP32_LDAP_NO_MEMORY;
138 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
139 ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
140 serverctrls, clientctrls, timelimit, sizelimit, message );
142 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
145 baseW = strAtoW( base );
146 if (!baseW) goto exit;
150 filterW = strAtoW( filter );
151 if (!filterW) goto exit;
154 attrsW = strarrayAtoW( attrs );
155 if (!attrsW) goto exit;
158 serverctrlsW = controlarrayAtoW( serverctrls );
159 if (!serverctrlsW) goto exit;
162 clientctrlsW = controlarrayAtoW( clientctrls );
163 if (!clientctrlsW) goto exit;
166 ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly,
167 serverctrlsW, clientctrlsW, timelimit, sizelimit, message );
172 strarrayfreeW( attrsW );
173 controlarrayfreeW( serverctrlsW );
174 controlarrayfreeW( clientctrlsW );
180 ULONG ldap_search_extW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
181 PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
182 PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
184 ULONG ret = LDAP_NOT_SUPPORTED;
186 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
187 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
190 ret = WLDAP32_LDAP_NO_MEMORY;
192 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
193 ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
194 serverctrls, clientctrls, timelimit, sizelimit, message );
196 if (!ld) return ~0UL;
199 baseU = strWtoU( base );
200 if (!baseU) goto exit;
203 filterU = strWtoU( filter );
204 if (!filterU) goto exit;
207 attrsU = strarrayWtoU( attrs );
208 if (!attrsU) goto exit;
211 serverctrlsU = controlarrayWtoU( serverctrls );
212 if (!serverctrlsU) goto exit;
215 clientctrlsU = controlarrayWtoU( clientctrls );
216 if (!clientctrlsU) goto exit;
219 tv.tv_sec = timelimit;
222 ret = ldap_search_ext( ld, baseU, scope, filterU, attrsU, attrsonly,
223 serverctrlsU, clientctrlsU, &tv, sizelimit, (int *)message );
228 strarrayfreeU( attrsU );
229 controlarrayfreeU( serverctrlsU );
230 controlarrayfreeU( clientctrlsU );
236 ULONG ldap_search_ext_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
237 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
238 PLDAPControlA *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
240 ULONG ret = LDAP_NOT_SUPPORTED;
242 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
243 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
245 ret = WLDAP32_LDAP_NO_MEMORY;
247 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, %p, 0x%08lx, %p)\n",
248 ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
249 serverctrls, clientctrls, timeout, sizelimit, res );
251 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
254 baseW = strAtoW( base );
255 if (!baseW) goto exit;
258 filterW = strAtoW( filter );
259 if (!filterW) goto exit;
262 attrsW = strarrayAtoW( attrs );
263 if (!attrsW) goto exit;
266 serverctrlsW = controlarrayAtoW( serverctrls );
267 if (!serverctrlsW) goto exit;
270 clientctrlsW = controlarrayAtoW( clientctrls );
271 if (!clientctrlsW) goto exit;
274 ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly,
275 serverctrlsW, clientctrlsW, timeout, sizelimit, res );
280 strarrayfreeW( attrsW );
281 controlarrayfreeW( serverctrlsW );
282 controlarrayfreeW( clientctrlsW );
288 ULONG ldap_search_ext_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
289 PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
290 PLDAPControlW *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
292 ULONG ret = LDAP_NOT_SUPPORTED;
294 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
295 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
297 ret = WLDAP32_LDAP_NO_MEMORY;
299 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, %p, 0x%08lx, %p)\n",
300 ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
301 serverctrls, clientctrls, timeout, sizelimit, res );
303 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
306 baseU = strWtoU( base );
307 if (!baseU) goto exit;
310 filterU = strWtoU( filter );
311 if (!filterU) goto exit;
314 attrsU = strarrayWtoU( attrs );
315 if (!attrsU) goto exit;
318 serverctrlsU = controlarrayWtoU( serverctrls );
319 if (!serverctrlsU) goto exit;
322 clientctrlsU = controlarrayWtoU( clientctrls );
323 if (!clientctrlsU) goto exit;
326 ret = ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly,
327 serverctrlsU, clientctrlsU, (struct timeval *)timeout, sizelimit, res );
332 strarrayfreeU( attrsU );
333 controlarrayfreeU( serverctrlsU );
334 controlarrayfreeU( clientctrlsU );
340 ULONG ldap_search_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
341 PCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
343 ULONG ret = LDAP_NOT_SUPPORTED;
345 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
347 ret = WLDAP32_LDAP_NO_MEMORY;
349 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld, debugstr_a(base),
350 scope, debugstr_a(filter), attrs, attrsonly, res );
352 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
355 baseW = strAtoW( base );
356 if (!baseW) goto exit;
359 filterW = strAtoW( filter );
360 if (!filterW) goto exit;
363 attrsW = strarrayAtoW( attrs );
364 if (!attrsW) goto exit;
367 ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
372 strarrayfreeW( attrsW );
378 ULONG ldap_search_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
379 PWCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
381 ULONG ret = LDAP_NOT_SUPPORTED;
383 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
385 ret = WLDAP32_LDAP_NO_MEMORY;
387 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld, debugstr_w(base),
388 scope, debugstr_w(filter), attrs, attrsonly, res );
390 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
393 baseU = strWtoU( base );
394 if (!baseU) goto exit;
397 filterU = strWtoU( filter );
398 if (!filterU) goto exit;
401 attrsU = strarrayWtoU( attrs );
402 if (!attrsU) goto exit;
405 ret = ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly,
406 NULL, NULL, NULL, 0, res );
411 strarrayfreeU( attrsU );
417 ULONG ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope,
418 const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
419 struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
421 ULONG ret = LDAP_NOT_SUPPORTED;
423 WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
425 ret = WLDAP32_LDAP_NO_MEMORY;
427 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld,
428 debugstr_a(base), scope, debugstr_a(filter), attrs,
429 attrsonly, timeout, res );
431 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
434 baseW = strAtoW( base );
435 if (!baseW) goto exit;
438 filterW = strAtoW( filter );
439 if (!filterW) goto exit;
442 attrsW = strarrayAtoW( attrs );
443 if (!attrsW) goto exit;
446 ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
452 strarrayfreeW( attrsW );
458 ULONG ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope,
459 const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly,
460 struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
462 ULONG ret = LDAP_NOT_SUPPORTED;
464 char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
466 ret = WLDAP32_LDAP_NO_MEMORY;
468 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld,
469 debugstr_w(base), scope, debugstr_w(filter), attrs,
470 attrsonly, timeout, res );
472 if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
475 baseU = strWtoU( base );
476 if (!baseU) goto exit;
479 filterU = strWtoU( filter );
480 if (!filterU) goto exit;
483 attrsU = strarrayWtoU( attrs );
484 if (!attrsU) goto exit;
487 ret = ldap_search_ext_s( ld, baseU, scope, filterU, attrsU, attrsonly,
488 NULL, NULL, (struct timeval *)timeout, 0, res );
493 strarrayfreeU( attrsU );
499 PLDAPSearch ldap_search_init_pageA( WLDAP32_LDAP *ld, const PCHAR name,
500 ULONG scope, const PCHAR filter, PCHAR attrs[],
501 ULONG attrsonly, PLDAPControlA* srvcontrols,
502 PLDAPControlA* clntcontrols, ULONG timelimit,
503 ULONG sizelimit, PLDAPSortKeyA* keys)
505 FIXME( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
506 ld, debugstr_a(name), scope, debugstr_a(filter), attrs,
507 attrsonly, srvcontrols, clntcontrols, timelimit, sizelimit, keys);
511 PLDAPSearch ldap_search_init_pageW( WLDAP32_LDAP *ld, const PWCHAR name,
512 ULONG scope, const PWCHAR filter, PWCHAR attrs[],
513 ULONG attrsonly, PLDAPControlW* srvcontrols,
514 PLDAPControlW* clntcontrols, ULONG timelimit,
515 ULONG sizelimit, PLDAPSortKeyW* keys)
517 FIXME( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
518 ld, debugstr_w(name), scope, debugstr_w(filter), attrs,
519 attrsonly, srvcontrols, clntcontrols, timelimit, sizelimit, keys);