2005-07-22 11:02:55 +02:00
|
|
|
/*
|
|
|
|
* WLDAP32 - LDAP support for Wine
|
|
|
|
*
|
|
|
|
* Copyright 2005 Hans Leidekker
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-22 11:02:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-09-05 17:23:34 +02:00
|
|
|
#ifdef HAVE_LDAP_H
|
|
|
|
#include <ldap.h>
|
|
|
|
#endif
|
2005-07-22 11:02:55 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
|
|
|
|
#include "winldap_private.h"
|
|
|
|
#include "wldap32.h"
|
2011-09-05 17:23:34 +02:00
|
|
|
#include "wine/debug.h"
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2020-02-05 21:44:14 +01:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-22 11:02:55 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
2020-02-05 21:44:14 +01:00
|
|
|
#endif
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_searchA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_searchW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
|
2005-07-22 11:02:55 +02:00
|
|
|
PCHAR attrs[], ULONG attrsonly )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-22 11:02:55 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(base),
|
2005-07-22 11:02:55 +02:00
|
|
|
scope, debugstr_a(filter), attrs, attrsonly );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (base) {
|
|
|
|
baseW = strAtoW( base );
|
|
|
|
if (!baseW) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterW = strAtoW( filter );
|
|
|
|
if (!filterW) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsW = strarrayAtoW( attrs );
|
|
|
|
if (!attrsW) goto exit;
|
|
|
|
}
|
2005-07-22 11:02:55 +02:00
|
|
|
|
|
|
|
ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-22 11:02:55 +02:00
|
|
|
strfreeW( baseW );
|
|
|
|
strfreeW( filterW );
|
|
|
|
strarrayfreeW( attrsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_searchW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Search a directory tree (asynchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* base [I] Starting point for the search.
|
|
|
|
* scope [I] Search scope. One of LDAP_SCOPE_BASE,
|
|
|
|
* LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE.
|
|
|
|
* filter [I] Search filter.
|
|
|
|
* attrs [I] Attributes to return.
|
|
|
|
* attrsonly [I] Return no values, only attributes.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Message ID of the search operation.
|
2009-01-05 12:40:28 +01:00
|
|
|
* Failure: ~0u
|
2006-04-21 16:38:01 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_result with the message ID to get the result of
|
|
|
|
* the operation. Cancel the operation by calling ldap_abandon
|
|
|
|
* with the message ID.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
|
2005-07-22 11:02:55 +02:00
|
|
|
PWCHAR attrs[], ULONG attrsonly )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-22 11:02:55 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
|
2005-11-18 17:29:32 +01:00
|
|
|
int msg;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(base),
|
2005-07-22 11:02:55 +02:00
|
|
|
scope, debugstr_w(filter), attrs, attrsonly );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (base) {
|
|
|
|
baseU = strWtoU( base );
|
|
|
|
if (!baseU) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterU = strWtoU( filter );
|
|
|
|
if (!filterU) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsU = strarrayWtoU( attrs );
|
|
|
|
if (!attrsU) goto exit;
|
|
|
|
}
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
|
2005-11-18 17:29:32 +01:00
|
|
|
NULL, NULL, NULL, 0, &msg );
|
|
|
|
|
|
|
|
if (ret == LDAP_SUCCESS)
|
|
|
|
ret = msg;
|
|
|
|
else
|
2009-01-05 12:40:28 +01:00
|
|
|
ret = ~0u;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-22 11:02:55 +02:00
|
|
|
strfreeU( baseU );
|
|
|
|
strfreeU( filterU );
|
|
|
|
strarrayfreeU( attrsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_extA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_search_extW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_extA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
|
2005-07-25 13:09:51 +02:00
|
|
|
PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
|
|
|
|
PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-25 13:09:51 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
|
|
|
|
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
|
2005-07-25 13:09:51 +02:00
|
|
|
ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
|
|
|
|
serverctrls, clientctrls, timelimit, sizelimit, message );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseW = strAtoW( base );
|
|
|
|
if (!baseW) goto exit;
|
|
|
|
}
|
|
|
|
if (filter)
|
|
|
|
{
|
|
|
|
filterW = strAtoW( filter );
|
|
|
|
if (!filterW) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsW = strarrayAtoW( attrs );
|
|
|
|
if (!attrsW) goto exit;
|
|
|
|
}
|
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsW = controlarrayAtoW( serverctrls );
|
|
|
|
if (!serverctrlsW) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsW = controlarrayAtoW( clientctrls );
|
|
|
|
if (!clientctrlsW) goto exit;
|
|
|
|
}
|
2005-07-25 13:09:51 +02:00
|
|
|
|
|
|
|
ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly,
|
|
|
|
serverctrlsW, clientctrlsW, timelimit, sizelimit, message );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-25 13:09:51 +02:00
|
|
|
strfreeW( baseW );
|
|
|
|
strfreeW( filterW );
|
|
|
|
strarrayfreeW( attrsW );
|
|
|
|
controlarrayfreeW( serverctrlsW );
|
|
|
|
controlarrayfreeW( clientctrlsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_extW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Search a directory tree (asynchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* base [I] Starting point for the search.
|
|
|
|
* scope [I] Search scope. One of LDAP_SCOPE_BASE,
|
|
|
|
* LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE.
|
|
|
|
* filter [I] Search filter.
|
|
|
|
* attrs [I] Attributes to return.
|
|
|
|
* attrsonly [I] Return no values, only attributes.
|
|
|
|
* serverctrls [I] Array of LDAP server controls.
|
|
|
|
* clientctrls [I] Array of LDAP client controls.
|
|
|
|
* timelimit [I] Timeout in seconds.
|
|
|
|
* sizelimit [I] Maximum number of entries to return. Zero means unlimited.
|
|
|
|
* message [O] Message ID of the search operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_result with the message ID to get the result of
|
|
|
|
* the operation. Cancel the operation by calling ldap_abandon
|
|
|
|
* with the message ID.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_extW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
|
2005-07-25 13:09:51 +02:00
|
|
|
PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
|
|
|
|
PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-25 13:09:51 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
|
|
|
|
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
|
2010-08-18 12:33:35 +02:00
|
|
|
struct timeval tv, *tvp = NULL;
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2005-08-02 16:42:10 +02:00
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-26 17:50:47 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
|
2005-07-25 13:09:51 +02:00
|
|
|
ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
|
|
|
|
serverctrls, clientctrls, timelimit, sizelimit, message );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (base) {
|
|
|
|
baseU = strWtoU( base );
|
|
|
|
if (!baseU) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterU = strWtoU( filter );
|
|
|
|
if (!filterU) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsU = strarrayWtoU( attrs );
|
|
|
|
if (!attrsU) goto exit;
|
|
|
|
}
|
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsU = controlarrayWtoU( serverctrls );
|
|
|
|
if (!serverctrlsU) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsU = controlarrayWtoU( clientctrls );
|
|
|
|
if (!clientctrlsU) goto exit;
|
|
|
|
}
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2010-08-18 12:33:35 +02:00
|
|
|
if (timelimit)
|
|
|
|
{
|
|
|
|
tv.tv_sec = timelimit;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
tvp = &tv;
|
|
|
|
}
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
|
2010-08-18 12:33:35 +02:00
|
|
|
serverctrlsU, clientctrlsU, tvp, sizelimit, (int *)message ));
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-25 13:09:51 +02:00
|
|
|
strfreeU( baseU );
|
|
|
|
strfreeU( filterU );
|
|
|
|
strarrayfreeU( attrsU );
|
|
|
|
controlarrayfreeU( serverctrlsU );
|
|
|
|
controlarrayfreeU( clientctrlsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_ext_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_search_ext_sW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_ext_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
|
2005-07-25 13:09:51 +02:00
|
|
|
PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
|
2005-07-26 17:50:47 +02:00
|
|
|
PLDAPControlA *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
|
2005-07-25 13:09:51 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-25 13:09:51 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
|
|
|
|
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n",
|
2005-07-25 13:09:51 +02:00
|
|
|
ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
|
2005-07-26 17:50:47 +02:00
|
|
|
serverctrls, clientctrls, timeout, sizelimit, res );
|
|
|
|
|
|
|
|
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseW = strAtoW( base );
|
|
|
|
if (!baseW) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterW = strAtoW( filter );
|
|
|
|
if (!filterW) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsW = strarrayAtoW( attrs );
|
|
|
|
if (!attrsW) goto exit;
|
|
|
|
}
|
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsW = controlarrayAtoW( serverctrls );
|
|
|
|
if (!serverctrlsW) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsW = controlarrayAtoW( clientctrls );
|
|
|
|
if (!clientctrlsW) goto exit;
|
|
|
|
}
|
2005-07-25 13:09:51 +02:00
|
|
|
|
|
|
|
ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly,
|
2005-07-26 17:50:47 +02:00
|
|
|
serverctrlsW, clientctrlsW, timeout, sizelimit, res );
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-25 13:09:51 +02:00
|
|
|
strfreeW( baseW );
|
|
|
|
strfreeW( filterW );
|
|
|
|
strarrayfreeW( attrsW );
|
|
|
|
controlarrayfreeW( serverctrlsW );
|
|
|
|
controlarrayfreeW( clientctrlsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_ext_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Search a directory tree (synchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* base [I] Starting point for the search.
|
|
|
|
* scope [I] Search scope. One of LDAP_SCOPE_BASE,
|
|
|
|
* LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE.
|
|
|
|
* filter [I] Search filter.
|
|
|
|
* attrs [I] Attributes to return.
|
|
|
|
* attrsonly [I] Return no values, only attributes.
|
|
|
|
* serverctrls [I] Array of LDAP server controls.
|
|
|
|
* clientctrls [I] Array of LDAP client controls.
|
|
|
|
* timeout [I] Timeout in seconds.
|
|
|
|
* sizelimit [I] Maximum number of entries to return. Zero means unlimited.
|
|
|
|
* res [O] Results of the search operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_msgfree to free the results.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_ext_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
|
2005-07-25 13:09:51 +02:00
|
|
|
PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
|
2005-07-26 17:50:47 +02:00
|
|
|
PLDAPControlW *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
|
2005-07-25 13:09:51 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-25 13:09:51 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
|
|
|
|
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n",
|
2005-07-25 13:09:51 +02:00
|
|
|
ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
|
2005-07-26 17:50:47 +02:00
|
|
|
serverctrls, clientctrls, timeout, sizelimit, res );
|
|
|
|
|
|
|
|
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseU = strWtoU( base );
|
|
|
|
if (!baseU) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterU = strWtoU( filter );
|
|
|
|
if (!filterU) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsU = strarrayWtoU( attrs );
|
|
|
|
if (!attrsU) goto exit;
|
|
|
|
}
|
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsU = controlarrayWtoU( serverctrls );
|
|
|
|
if (!serverctrlsU) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsU = controlarrayWtoU( clientctrls );
|
|
|
|
if (!clientctrlsU) goto exit;
|
|
|
|
}
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
|
2008-10-20 12:22:13 +02:00
|
|
|
serverctrlsU, clientctrlsU, (struct timeval *)timeout,
|
|
|
|
sizelimit, res ));
|
2005-07-25 13:09:51 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-25 13:09:51 +02:00
|
|
|
strfreeU( baseU );
|
|
|
|
strfreeU( filterU );
|
|
|
|
strarrayfreeU( attrsU );
|
|
|
|
controlarrayfreeU( serverctrlsU );
|
|
|
|
controlarrayfreeU( clientctrlsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_search_sW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
|
2005-07-22 11:02:55 +02:00
|
|
|
PCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-22 11:02:55 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_a(base),
|
2005-07-22 11:02:55 +02:00
|
|
|
scope, debugstr_a(filter), attrs, attrsonly, res );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseW = strAtoW( base );
|
|
|
|
if (!baseW) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterW = strAtoW( filter );
|
|
|
|
if (!filterW) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsW = strarrayAtoW( attrs );
|
|
|
|
if (!attrsW) goto exit;
|
|
|
|
}
|
2005-07-22 11:02:55 +02:00
|
|
|
|
|
|
|
ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-22 11:02:55 +02:00
|
|
|
strfreeW( baseW );
|
|
|
|
strfreeW( filterW );
|
|
|
|
strarrayfreeW( attrsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Search a directory tree (synchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* base [I] Starting point for the search.
|
|
|
|
* scope [I] Search scope. One of LDAP_SCOPE_BASE,
|
|
|
|
* LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE.
|
|
|
|
* filter [I] Search filter.
|
|
|
|
* attrs [I] Attributes to return.
|
|
|
|
* attrsonly [I] Return no values, only attributes.
|
|
|
|
* res [O] Results of the search operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_msgfree to free the results.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
|
2005-07-22 11:02:55 +02:00
|
|
|
PWCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-22 11:02:55 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_w(base),
|
2005-07-22 11:02:55 +02:00
|
|
|
scope, debugstr_w(filter), attrs, attrsonly, res );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseU = strWtoU( base );
|
|
|
|
if (!baseU) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterU = strWtoU( filter );
|
|
|
|
if (!filterU) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsU = strarrayWtoU( attrs );
|
|
|
|
if (!attrsU) goto exit;
|
|
|
|
}
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
|
2008-10-20 12:22:13 +02:00
|
|
|
NULL, NULL, NULL, 0, res ));
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-22 11:02:55 +02:00
|
|
|
strfreeU( baseU );
|
|
|
|
strfreeU( filterU );
|
|
|
|
strarrayfreeU( attrsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_stA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_search_stW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope,
|
2005-07-22 11:02:55 +02:00
|
|
|
const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
|
|
|
|
struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-22 11:02:55 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld,
|
2005-07-22 11:02:55 +02:00
|
|
|
debugstr_a(base), scope, debugstr_a(filter), attrs,
|
|
|
|
attrsonly, timeout, res );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseW = strAtoW( base );
|
|
|
|
if (!baseW) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterW = strAtoW( filter );
|
|
|
|
if (!filterW) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsW = strarrayAtoW( attrs );
|
|
|
|
if (!attrsW) goto exit;
|
|
|
|
}
|
2005-07-22 11:02:55 +02:00
|
|
|
|
|
|
|
ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
|
|
|
|
timeout, res );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-22 11:02:55 +02:00
|
|
|
strfreeW( baseW );
|
|
|
|
strfreeW( filterW );
|
|
|
|
strarrayfreeW( attrsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:38:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_search_stW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Search a directory tree (synchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* base [I] Starting point for the search.
|
|
|
|
* scope [I] Search scope. One of LDAP_SCOPE_BASE,
|
|
|
|
* LDAP_SCOPE_ONELEVEL and LDAP_SCOPE_SUBTREE.
|
|
|
|
* filter [I] Search filter.
|
|
|
|
* attrs [I] Attributes to return.
|
|
|
|
* attrsonly [I] Return no values, only attributes.
|
|
|
|
* timeout [I] Timeout in seconds.
|
|
|
|
* res [O] Results of the search operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_msgfree to free the results.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope,
|
2005-07-22 11:02:55 +02:00
|
|
|
const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly,
|
|
|
|
struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-22 11:02:55 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 17:50:47 +02:00
|
|
|
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld,
|
2005-07-22 11:02:55 +02:00
|
|
|
debugstr_w(base), scope, debugstr_w(filter), attrs,
|
|
|
|
attrsonly, timeout, res );
|
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
if (base) {
|
|
|
|
baseU = strWtoU( base );
|
|
|
|
if (!baseU) goto exit;
|
|
|
|
}
|
|
|
|
if (filter) {
|
|
|
|
filterU = strWtoU( filter );
|
|
|
|
if (!filterU) goto exit;
|
|
|
|
}
|
|
|
|
if (attrs) {
|
|
|
|
attrsU = strarrayWtoU( attrs );
|
|
|
|
if (!attrsU) goto exit;
|
|
|
|
}
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
|
2008-10-20 12:22:13 +02:00
|
|
|
NULL, NULL, (struct timeval *)timeout, 0, res ));
|
2005-07-22 11:02:55 +02:00
|
|
|
|
2005-07-26 17:50:47 +02:00
|
|
|
exit:
|
2005-07-22 11:02:55 +02:00
|
|
|
strfreeU( baseU );
|
|
|
|
strfreeU( filterU );
|
|
|
|
strarrayfreeU( attrsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|