Implement ldap_search* functions.

This commit is contained in:
Hans Leidekker 2005-07-22 09:02:55 +00:00 committed by Alexandre Julliard
parent b8585b8d0c
commit 05f18059f3
4 changed files with 267 additions and 1 deletions

View File

@ -11,7 +11,8 @@ C_SRCS = \
ber.c \
bind.c \
init.c \
main.c
main.c \
search.c
@MAKE_DLL_RULES@

222
dlls/wldap32/search.c Normal file
View File

@ -0,0 +1,222 @@
/*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#ifdef HAVE_LDAP
#include <ldap.h>
#else
#define LDAP_SUCCESS 0x00
#define LDAP_NOT_SUPPORTED 0x5c
#endif
#include "winldap_private.h"
#include "wldap32.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
ULONG ldap_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
PCHAR attrs[], ULONG attrsonly )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
WCHAR *baseW, *filterW, **attrsW;
TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_a(base),
scope, debugstr_a(filter), attrs, attrsonly );
baseW = strAtoW( base );
if (!baseW) return LDAP_NO_MEMORY;
filterW = strAtoW( filter );
if (!filterW) return LDAP_NO_MEMORY;
attrsW = strarrayAtoW( attrs );
if (!attrsW) return LDAP_NO_MEMORY;
ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
#endif
return ret;
}
ULONG ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
PWCHAR attrs[], ULONG attrsonly )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *baseU, *filterU, **attrsU;
TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx)\n", ld, debugstr_w(base),
scope, debugstr_w(filter), attrs, attrsonly );
baseU = strWtoU( base );
if (!baseU) return LDAP_NO_MEMORY;
filterU = strWtoU( filter );
if (!filterU) return LDAP_NO_MEMORY;
attrsU = strarrayWtoU( attrs );
if (!attrsU) return LDAP_NO_MEMORY;
ret = ldap_search( ld, baseU, scope, filterU, attrsU, attrsonly );
strfreeU( baseU );
strfreeU( filterU );
strarrayfreeU( attrsU );
#endif
return ret;
}
ULONG ldap_search_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
PCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
WCHAR *baseW, *filterW, **attrsW;
TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld, debugstr_a(base),
scope, debugstr_a(filter), attrs, attrsonly, res );
baseW = strAtoW( base );
if (!baseW) return LDAP_NO_MEMORY;
filterW = strAtoW( filter );
if (!filterW) return LDAP_NO_MEMORY;
attrsW = strarrayAtoW( attrs );
if (!attrsW) return LDAP_NO_MEMORY;
ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
#endif
return ret;
}
ULONG ldap_search_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
PWCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *baseU, *filterU, **attrsU;
TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p)\n", ld, debugstr_w(base),
scope, debugstr_w(filter), attrs, attrsonly, res );
baseU = strWtoU( base );
if (!baseU) return LDAP_NO_MEMORY;
filterU = strWtoU( filter );
if (!filterU) return LDAP_NO_MEMORY;
attrsU = strarrayWtoU( attrs );
if (!attrsU) return LDAP_NO_MEMORY;
ret = ldap_search_s( ld, baseU, scope, filterU, attrsU, attrsonly, res );
strfreeU( baseU );
strfreeU( filterU );
strarrayfreeU( attrsU );
#endif
return ret;
}
ULONG ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope,
const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
WCHAR *baseW, *filterW, **attrsW;
TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld,
debugstr_a(base), scope, debugstr_a(filter), attrs,
attrsonly, timeout, res );
baseW = strAtoW( base );
if (!baseW) return LDAP_NO_MEMORY;
filterW = strAtoW( filter );
if (!filterW) return LDAP_NO_MEMORY;
attrsW = strarrayAtoW( attrs );
if (!attrsW) return LDAP_NO_MEMORY;
ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
timeout, res );
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
#endif
return ret;
}
ULONG ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope,
const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly,
struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *baseU, *filterU, **attrsU;
TRACE( "(%p, %s, 0x%08lx, %s, %p, 0x%08lx, %p, %p)\n", ld,
debugstr_w(base), scope, debugstr_w(filter), attrs,
attrsonly, timeout, res );
baseU = strWtoU( base );
if (!baseU) return LDAP_NO_MEMORY;
filterU = strWtoU( filter );
if (!filterU) return LDAP_NO_MEMORY;
attrsU = strarrayWtoU( attrs );
if (!attrsU) return LDAP_NO_MEMORY;
ret = ldap_search_st( ld, baseU, scope, filterU, attrsU, attrsonly,
(struct timeval *)timeout, res );
strfreeU( baseU );
strfreeU( filterU );
strarrayfreeU( attrsU );
#endif
return ret;
}

View File

@ -49,6 +49,32 @@ typedef struct ldap
ULONG ld_options;
} WLDAP32_LDAP, *WLDAP32_PLDAP;
typedef struct l_timeval
{
LONG tv_sec;
LONG tv_usec;
} LDAP_TIMEVAL, *PLDAP_TIMEVAL;
typedef struct ldapmsg
{
ULONG lm_msgid;
ULONG lm_msgtype;
PVOID lm_ber;
struct ldapmsg *lm_chain;
struct ldapmsg *lm_next;
ULONG lm_time;
WLDAP32_PLDAP Connection;
PVOID Request;
ULONG lm_returncode;
USHORT lm_referral;
BOOLEAN lm_chased;
BOOLEAN lm_eom;
BOOLEAN ConnectionReferenced;
} WLDAP32_LDAPMessage, *WLDAP32_PLDAPMessage;
ULONG ldap_bindA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG);
ULONG ldap_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR,ULONG);
ULONG ldap_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG);
@ -57,6 +83,14 @@ WLDAP32_LDAP *ldap_initA(const PCHAR,ULONG);
WLDAP32_LDAP *ldap_initW(const PWCHAR,ULONG);
WLDAP32_LDAP *ldap_openA(PCHAR,ULONG);
WLDAP32_LDAP *ldap_openW(PWCHAR,ULONG);
ULONG ldap_searchA(WLDAP32_LDAP*,PCHAR,ULONG,PCHAR,PCHAR[],ULONG);
ULONG ldap_searchW(WLDAP32_LDAP*,PWCHAR,ULONG,PWCHAR,PWCHAR[],ULONG);
ULONG ldap_search_sA(WLDAP32_LDAP*,PCHAR,ULONG,PCHAR,PCHAR[],ULONG,WLDAP32_LDAPMessage**);
ULONG ldap_search_sW(WLDAP32_LDAP*,PWCHAR,ULONG,PWCHAR,PWCHAR[],ULONG,WLDAP32_LDAPMessage**);
ULONG ldap_search_stA(WLDAP32_LDAP*,const PCHAR,ULONG,const PCHAR,PCHAR[],ULONG,
struct l_timeval*,WLDAP32_LDAPMessage**);
ULONG ldap_search_stW(WLDAP32_LDAP*,const PWCHAR,ULONG,const PWCHAR,PWCHAR[],ULONG,
struct l_timeval*,WLDAP32_LDAPMessage**);
ULONG ldap_simple_bindA(WLDAP32_LDAP*,PCHAR,PCHAR);
ULONG ldap_simple_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR);
ULONG ldap_simple_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR);

View File

@ -25,6 +25,15 @@
@ cdecl ldap_open(str long) ldap_openA
@ cdecl ldap_openA(str long)
@ cdecl ldap_openW(wstr long)
@ cdecl ldap_search(ptr str long str ptr long) ldap_searchA
@ cdecl ldap_searchA(ptr str long str ptr long)
@ cdecl ldap_searchW(ptr wstr long wstr ptr long)
@ cdecl ldap_search_s(ptr str long str ptr long) ldap_search_sA
@ cdecl ldap_search_sA(ptr str long str ptr long)
@ cdecl ldap_search_sW(ptr wstr long wstr ptr long)
@ cdecl ldap_search_st(ptr str long str ptr long ptr ptr) ldap_search_stA
@ cdecl ldap_search_stA(ptr str long str ptr long ptr ptr)
@ cdecl ldap_search_stW(ptr wstr long wstr ptr long ptr ptr)
@ cdecl ldap_simple_bind(ptr str str) ldap_simple_bindA
@ cdecl ldap_simple_bindA(ptr str str)
@ cdecl ldap_simple_bindW(ptr wstr wstr)