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
;
89 ret
= WLDAP32_LDAP_NO_MEMORY
;
91 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld
, debugstr_w(base
),
92 scope
, debugstr_w(filter
), attrs
, attrsonly
);
97 baseU
= strWtoU( base
);
98 if (!baseU
) goto exit
;
101 filterU
= strWtoU( filter
);
102 if (!filterU
) goto exit
;
105 attrsU
= strarrayWtoU( attrs
);
106 if (!attrsU
) goto exit
;
109 ret
= ldap_search( ld
, baseU
, scope
, filterU
, attrsU
, attrsonly
);
114 strarrayfreeU( attrsU
);
120 ULONG
ldap_search_extA( WLDAP32_LDAP
*ld
, PCHAR base
, ULONG scope
,
121 PCHAR filter
, PCHAR attrs
[], ULONG attrsonly
, PLDAPControlA
*serverctrls
,
122 PLDAPControlA
*clientctrls
, ULONG timelimit
, ULONG sizelimit
, ULONG
*message
)
124 ULONG ret
= LDAP_NOT_SUPPORTED
;
126 WCHAR
*baseW
= NULL
, *filterW
= NULL
, **attrsW
= NULL
;
127 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
129 ret
= WLDAP32_LDAP_NO_MEMORY
;
131 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
132 ld
, debugstr_a(base
), scope
, debugstr_a(filter
), attrs
, attrsonly
,
133 serverctrls
, clientctrls
, timelimit
, sizelimit
, message
);
135 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
138 baseW
= strAtoW( base
);
139 if (!baseW
) goto exit
;
143 filterW
= strAtoW( filter
);
144 if (!filterW
) goto exit
;
147 attrsW
= strarrayAtoW( attrs
);
148 if (!attrsW
) goto exit
;
151 serverctrlsW
= controlarrayAtoW( serverctrls
);
152 if (!serverctrlsW
) goto exit
;
155 clientctrlsW
= controlarrayAtoW( clientctrls
);
156 if (!clientctrlsW
) goto exit
;
159 ret
= ldap_search_extW( ld
, baseW
, scope
, filterW
, attrsW
, attrsonly
,
160 serverctrlsW
, clientctrlsW
, timelimit
, sizelimit
, message
);
165 strarrayfreeW( attrsW
);
166 controlarrayfreeW( serverctrlsW
);
167 controlarrayfreeW( clientctrlsW
);
173 ULONG
ldap_search_extW( WLDAP32_LDAP
*ld
, PWCHAR base
, ULONG scope
,
174 PWCHAR filter
, PWCHAR attrs
[], ULONG attrsonly
, PLDAPControlW
*serverctrls
,
175 PLDAPControlW
*clientctrls
, ULONG timelimit
, ULONG sizelimit
, ULONG
*message
)
177 ULONG ret
= LDAP_NOT_SUPPORTED
;
179 char *baseU
= NULL
, *filterU
= NULL
, **attrsU
= NULL
;
180 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
183 ret
= WLDAP32_LDAP_NO_MEMORY
;
185 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, 0x%08lx, 0x%08lx, %p)\n",
186 ld
, debugstr_w(base
), scope
, debugstr_w(filter
), attrs
, attrsonly
,
187 serverctrls
, clientctrls
, timelimit
, sizelimit
, message
);
189 if (!ld
) return ~0UL;
192 baseU
= strWtoU( base
);
193 if (!baseU
) goto exit
;
196 filterU
= strWtoU( filter
);
197 if (!filterU
) goto exit
;
200 attrsU
= strarrayWtoU( attrs
);
201 if (!attrsU
) goto exit
;
204 serverctrlsU
= controlarrayWtoU( serverctrls
);
205 if (!serverctrlsU
) goto exit
;
208 clientctrlsU
= controlarrayWtoU( clientctrls
);
209 if (!clientctrlsU
) goto exit
;
212 tv
.tv_sec
= timelimit
;
215 ret
= ldap_search_ext( ld
, baseU
, scope
, filterU
, attrsU
, attrsonly
,
216 serverctrlsU
, clientctrlsU
, &tv
, sizelimit
, (int *)message
);
221 strarrayfreeU( attrsU
);
222 controlarrayfreeU( serverctrlsU
);
223 controlarrayfreeU( clientctrlsU
);
229 ULONG
ldap_search_ext_sA( WLDAP32_LDAP
*ld
, PCHAR base
, ULONG scope
,
230 PCHAR filter
, PCHAR attrs
[], ULONG attrsonly
, PLDAPControlA
*serverctrls
,
231 PLDAPControlA
*clientctrls
, struct l_timeval
* timeout
, ULONG sizelimit
, WLDAP32_LDAPMessage
**res
)
233 ULONG ret
= LDAP_NOT_SUPPORTED
;
235 WCHAR
*baseW
= NULL
, *filterW
= NULL
, **attrsW
= NULL
;
236 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
238 ret
= WLDAP32_LDAP_NO_MEMORY
;
240 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, %p, 0x%08lx, %p)\n",
241 ld
, debugstr_a(base
), scope
, debugstr_a(filter
), attrs
, attrsonly
,
242 serverctrls
, clientctrls
, timeout
, sizelimit
, res
);
244 if (!ld
|| !res
) return WLDAP32_LDAP_PARAM_ERROR
;
247 baseW
= strAtoW( base
);
248 if (!baseW
) goto exit
;
251 filterW
= strAtoW( filter
);
252 if (!filterW
) goto exit
;
255 attrsW
= strarrayAtoW( attrs
);
256 if (!attrsW
) goto exit
;
259 serverctrlsW
= controlarrayAtoW( serverctrls
);
260 if (!serverctrlsW
) goto exit
;
263 clientctrlsW
= controlarrayAtoW( clientctrls
);
264 if (!clientctrlsW
) goto exit
;
267 ret
= ldap_search_ext_sW( ld
, baseW
, scope
, filterW
, attrsW
, attrsonly
,
268 serverctrlsW
, clientctrlsW
, timeout
, sizelimit
, res
);
273 strarrayfreeW( attrsW
);
274 controlarrayfreeW( serverctrlsW
);
275 controlarrayfreeW( clientctrlsW
);
281 ULONG
ldap_search_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR base
, ULONG scope
,
282 PWCHAR filter
, PWCHAR attrs
[], ULONG attrsonly
, PLDAPControlW
*serverctrls
,
283 PLDAPControlW
*clientctrls
, struct l_timeval
* timeout
, ULONG sizelimit
, WLDAP32_LDAPMessage
**res
)
285 ULONG ret
= LDAP_NOT_SUPPORTED
;
287 char *baseU
= NULL
, *filterU
= NULL
, **attrsU
= NULL
;
288 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
290 ret
= WLDAP32_LDAP_NO_MEMORY
;
292 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p, %p, 0x%08lx, %p)\n",
293 ld
, debugstr_w(base
), scope
, debugstr_w(filter
), attrs
, attrsonly
,
294 serverctrls
, clientctrls
, timeout
, sizelimit
, res
);
296 if (!ld
|| !res
) return WLDAP32_LDAP_PARAM_ERROR
;
299 baseU
= strWtoU( base
);
300 if (!baseU
) goto exit
;
303 filterU
= strWtoU( filter
);
304 if (!filterU
) goto exit
;
307 attrsU
= strarrayWtoU( attrs
);
308 if (!attrsU
) goto exit
;
311 serverctrlsU
= controlarrayWtoU( serverctrls
);
312 if (!serverctrlsU
) goto exit
;
315 clientctrlsU
= controlarrayWtoU( clientctrls
);
316 if (!clientctrlsU
) goto exit
;
319 ret
= ldap_search_ext_s( ld
, baseU
, scope
, filterU
, attrsU
, attrsonly
,
320 serverctrlsU
, clientctrlsU
, (struct timeval
*)timeout
, sizelimit
, res
);
325 strarrayfreeU( attrsU
);
326 controlarrayfreeU( serverctrlsU
);
327 controlarrayfreeU( clientctrlsU
);
333 ULONG
ldap_search_sA( WLDAP32_LDAP
*ld
, PCHAR base
, ULONG scope
, PCHAR filter
,
334 PCHAR attrs
[], ULONG attrsonly
, WLDAP32_LDAPMessage
**res
)
336 ULONG ret
= LDAP_NOT_SUPPORTED
;
338 WCHAR
*baseW
= NULL
, *filterW
= NULL
, **attrsW
= NULL
;
340 ret
= WLDAP32_LDAP_NO_MEMORY
;
342 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld
, debugstr_a(base
),
343 scope
, debugstr_a(filter
), attrs
, attrsonly
, res
);
345 if (!ld
|| !res
) return WLDAP32_LDAP_PARAM_ERROR
;
348 baseW
= strAtoW( base
);
349 if (!baseW
) goto exit
;
352 filterW
= strAtoW( filter
);
353 if (!filterW
) goto exit
;
356 attrsW
= strarrayAtoW( attrs
);
357 if (!attrsW
) goto exit
;
360 ret
= ldap_search_sW( ld
, baseW
, scope
, filterW
, attrsW
, attrsonly
, res
);
365 strarrayfreeW( attrsW
);
371 ULONG
ldap_search_sW( WLDAP32_LDAP
*ld
, PWCHAR base
, ULONG scope
, PWCHAR filter
,
372 PWCHAR attrs
[], ULONG attrsonly
, WLDAP32_LDAPMessage
**res
)
374 ULONG ret
= LDAP_NOT_SUPPORTED
;
376 char *baseU
= NULL
, *filterU
= NULL
, **attrsU
= NULL
;
378 ret
= WLDAP32_LDAP_NO_MEMORY
;
380 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld
, debugstr_w(base
),
381 scope
, debugstr_w(filter
), attrs
, attrsonly
, res
);
383 if (!ld
|| !res
) return WLDAP32_LDAP_PARAM_ERROR
;
386 baseU
= strWtoU( base
);
387 if (!baseU
) goto exit
;
390 filterU
= strWtoU( filter
);
391 if (!filterU
) goto exit
;
394 attrsU
= strarrayWtoU( attrs
);
395 if (!attrsU
) goto exit
;
398 ret
= ldap_search_s( ld
, baseU
, scope
, filterU
, attrsU
, attrsonly
, res
);
403 strarrayfreeU( attrsU
);
409 ULONG
ldap_search_stA( WLDAP32_LDAP
*ld
, const PCHAR base
, ULONG scope
,
410 const PCHAR filter
, PCHAR attrs
[], ULONG attrsonly
,
411 struct l_timeval
*timeout
, WLDAP32_LDAPMessage
**res
)
413 ULONG ret
= LDAP_NOT_SUPPORTED
;
415 WCHAR
*baseW
= NULL
, *filterW
= NULL
, **attrsW
= NULL
;
417 ret
= WLDAP32_LDAP_NO_MEMORY
;
419 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld
,
420 debugstr_a(base
), scope
, debugstr_a(filter
), attrs
,
421 attrsonly
, timeout
, res
);
423 if (!ld
|| !res
) return WLDAP32_LDAP_PARAM_ERROR
;
426 baseW
= strAtoW( base
);
427 if (!baseW
) goto exit
;
430 filterW
= strAtoW( filter
);
431 if (!filterW
) goto exit
;
434 attrsW
= strarrayAtoW( attrs
);
435 if (!attrsW
) goto exit
;
438 ret
= ldap_search_stW( ld
, baseW
, scope
, filterW
, attrsW
, attrsonly
,
444 strarrayfreeW( attrsW
);
450 ULONG
ldap_search_stW( WLDAP32_LDAP
*ld
, const PWCHAR base
, ULONG scope
,
451 const PWCHAR filter
, PWCHAR attrs
[], ULONG attrsonly
,
452 struct l_timeval
*timeout
, WLDAP32_LDAPMessage
**res
)
454 ULONG ret
= LDAP_NOT_SUPPORTED
;
456 char *baseU
= NULL
, *filterU
= NULL
, **attrsU
= NULL
;
458 ret
= WLDAP32_LDAP_NO_MEMORY
;
460 TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld
,
461 debugstr_w(base
), scope
, debugstr_w(filter
), attrs
,
462 attrsonly
, timeout
, res
);
464 if (!ld
|| !res
) return WLDAP32_LDAP_PARAM_ERROR
;
467 baseU
= strWtoU( base
);
468 if (!baseU
) goto exit
;
471 filterU
= strWtoU( filter
);
472 if (!filterU
) goto exit
;
475 attrsU
= strarrayWtoU( attrs
);
476 if (!attrsU
) goto exit
;
479 ret
= ldap_search_st( ld
, baseU
, scope
, filterU
, attrsU
, attrsonly
,
480 (struct timeval
*)timeout
, res
);
485 strarrayfreeU( attrsU
);