Commit 22b26a20 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wldap32: Move support for search functions to the Unix library.

parent 0f3f49e1
......@@ -214,7 +214,7 @@ PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
if (!ld || !entry) return NULL;
retU = ldap_get_dn( ld->ld, entry );
retU = ldap_get_dn( ld->ld, entry->Request );
ret = strUtoW( retU );
ldap_memfree( retU );
......
......@@ -152,7 +152,7 @@ ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *re
if (!ld || !res) return ~0u;
ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free ) );
ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res->Request, &error, NULL, NULL, NULL, NULL, free ) );
if (ret == WLDAP32_LDAP_SUCCESS)
ret = error;
else
......
......@@ -26,6 +26,7 @@
#ifdef HAVE_LDAP
#include <stdarg.h>
#include <sys/time.h>
#ifdef HAVE_LDAP_H
# include <ldap.h>
#endif
......@@ -49,6 +50,7 @@ C_ASSERT( sizeof(LDAPModU) == sizeof(LDAPMod) );
C_ASSERT( sizeof(LDAPControlU) == sizeof(LDAPControl) );
C_ASSERT( sizeof(LDAPSortKeyU) == sizeof(LDAPSortKey) );
C_ASSERT( sizeof(LDAPVLVInfoU) == sizeof(LDAPVLVInfo) );
C_ASSERT( sizeof(struct timevalU) == sizeof(struct timeval) );
static LDAPMod *nullattrs[] = { NULL };
......@@ -294,6 +296,11 @@ int WINAPIV wrap_ber_scanf( void *ber, char *fmt, ... )
return ret;
}
int CDECL wrap_ldap_abandon_ext( void *ld, int msgid, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
{
return ldap_abandon_ext( ld, msgid, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
int CDECL wrap_ldap_add_ext( void *ld, const char *dn, LDAPModU **attrs, LDAPControlU **serverctrls,
LDAPControlU **clientctrls, ULONG *msg )
{
......@@ -309,11 +316,6 @@ int CDECL wrap_ldap_add_ext_s( void *ld, const char *dn, LDAPModU **attrs, LDAPC
(LDAPControl **)clientctrls );
}
void CDECL wrap_ldap_control_free( LDAPControlU *control )
{
ldap_control_free( (LDAPControl *)control );
}
int CDECL wrap_ldap_compare_ext( void *ld, const char *dn, const char *attrs, struct bervalU *value,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, ULONG *msg )
{
......@@ -329,6 +331,21 @@ int CDECL wrap_ldap_compare_ext_s( void *ld, const char *dn, const char *attrs,
(LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
void CDECL wrap_ldap_control_free( LDAPControlU *control )
{
ldap_control_free( (LDAPControl *)control );
}
int CDECL wrap_ldap_count_entries( void *ld, void *chain )
{
return ldap_count_entries( ld, chain );
}
int CDECL wrap_ldap_count_references( void *ld, void *chain )
{
return ldap_count_references( ld, chain );
}
int CDECL wrap_ldap_create_sort_control( void *ld, LDAPSortKeyU **keylist, int critical, LDAPControlU **control )
{
return ldap_create_sort_control( ld, (LDAPSortKey **)keylist, critical, (LDAPControl **)control );
......@@ -352,17 +369,57 @@ int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serve
return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
char * CDECL wrap_ldap_first_attribute( void *ld, void *entry, void **ber )
{
return ldap_first_attribute( ld, entry, (BerElement **)ber );
}
void * CDECL wrap_ldap_first_entry( void *ld, void *chain )
{
return ldap_first_entry( ld, chain );
}
void * CDECL wrap_ldap_first_reference( void *ld, void *chain )
{
return ldap_first_reference( ld, chain );
}
void CDECL wrap_ldap_memfree( void *ptr )
{
return ldap_memfree( ptr );
}
int CDECL wrap_ldap_msgfree( void *msg )
{
return ldap_msgfree( msg );
}
char * CDECL wrap_ldap_next_attribute( void *ld, void *entry, void *ber )
{
return ldap_next_attribute( ld, entry, ber );
}
void * CDECL wrap_ldap_next_entry( void *ld, void *entry )
{
return ldap_next_entry( ld, entry );
}
void * CDECL wrap_ldap_next_reference( void *ld, void *entry )
{
return ldap_next_reference( ld, entry );
}
int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matcheddn, char **errmsg,
char ***referrals, LDAPControlU ***serverctrls, int free )
{
return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
}
int CDECL wrap_ldap_result( void *ld, int msgid, int all, struct timevalU *timeout, void **result )
{
return ldap_result( ld, msgid, all, (struct timeval *)timeout, (LDAPMessage **)result );
}
int CDECL wrap_ldap_sasl_bind( void *ld, const char *dn, const char *mech, struct bervalU *cred,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, int *msgid )
{
......@@ -393,6 +450,23 @@ int CDECL wrap_ldap_sasl_interactive_bind_s( void *ld, const char *dn, const cha
wrap_sasl_interact, defaults );
}
int CDECL wrap_ldap_search_ext( void *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, struct timevalU *timeout,
int sizelimit, ULONG *msg )
{
return ldap_search_ext( ld, base, scope, filter, attrs, attrsonly, (LDAPControl **)serverctrls,
(LDAPControl **)clientctrls, (struct timeval *)timeout, sizelimit, (int *)msg );
}
int CDECL wrap_ldap_search_ext_s( void *ld, const char *base, int scope, const char *filter, char **attrs,
int attrsonly, LDAPControlU **serverctrls, LDAPControlU **clientctrls,
struct timevalU *timeout, int sizelimit, void **result )
{
return ldap_search_ext_s( ld, base, scope, filter, attrs, attrsonly, (LDAPControl **)serverctrls,
(LDAPControl **)clientctrls, (struct timeval *)timeout, sizelimit,
(LDAPMessage **)result );
}
int CDECL wrap_ldap_unbind_ext( void *ld, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
{
return ldap_unbind_ext( ld, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
......@@ -422,20 +496,33 @@ static const struct ldap_funcs funcs =
wrap_ber_skip_tag,
wrap_ber_printf,
wrap_ber_scanf,
wrap_ldap_abandon_ext,
wrap_ldap_add_ext,
wrap_ldap_add_ext_s,
wrap_ldap_compare_ext,
wrap_ldap_compare_ext_s,
wrap_ldap_control_free,
wrap_ldap_count_entries,
wrap_ldap_count_references,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
wrap_ldap_first_reference,
wrap_ldap_memfree,
wrap_ldap_msgfree,
wrap_ldap_next_attribute,
wrap_ldap_next_entry,
wrap_ldap_next_reference,
wrap_ldap_parse_result,
wrap_ldap_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
wrap_ldap_sasl_interactive_bind_s,
wrap_ldap_search_ext,
wrap_ldap_search_ext_s,
wrap_ldap_unbind_ext,
wrap_ldap_unbind_ext_s,
wrap_ldap_value_free_len,
......@@ -448,5 +535,4 @@ NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *p
*(const struct ldap_funcs **)ptr_out = &funcs;
return STATUS_SUCCESS;
}
#endif /* HAVE_LDAP */
......@@ -60,6 +60,12 @@ typedef struct
void *ldvlv_extradata;
} LDAPVLVInfoU;
typedef struct timevalU
{
unsigned long tv_sec;
unsigned long tv_usec;
} LDAP_TIMEVALU;
#ifndef SASL_CB_LIST_END
#define SASL_CB_LIST_END 0
#define SASL_CB_USER 0x4001
......@@ -90,6 +96,7 @@ extern unsigned int CDECL wrap_ber_skip_tag(void *, unsigned int *) DECLSPEC_HID
extern int WINAPIV wrap_ber_printf(void *, char *, ...) DECLSPEC_HIDDEN;
extern int WINAPIV wrap_ber_scanf(void *, char *, ...) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_abandon_ext(void *, int, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_add_ext(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **,
ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_add_ext_s(void *, const char *, LDAPModU **, LDAPControlU **,
......@@ -99,19 +106,33 @@ extern int CDECL wrap_ldap_compare_ext(void *, const char *, const char *, struc
extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_control_free(LDAPControlU *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_count_entries(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_count_references(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_reference(void *, void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_msgfree(void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_next_attribute(void *, void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_reference(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
int) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_result(void *, int, int, struct timevalU *, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, struct bervalU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_interactive_bind_s(void *, const char *, const char *, LDAPControlU **,
LDAPControlU **, unsigned int, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_search_ext(void *, const char *, int, const char *, char **, int, LDAPControlU **,
LDAPControlU **, struct timevalU *, int, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_search_ext_s(void *, const char *, int, const char *, char **, int, LDAPControlU **,
LDAPControlU **, struct timevalU *, int, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_unbind_ext(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_unbind_ext_s(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_value_free_len(struct bervalU **) DECLSPEC_HIDDEN;
......@@ -131,6 +152,7 @@ struct ldap_funcs
int (WINAPIV *ber_printf)(void *, char *, ...);
int (WINAPIV *ber_scanf)(void *, char *, ...);
int (CDECL *ldap_abandon_ext)(void *, int, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_add_ext)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_add_ext_s)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_compare_ext)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
......@@ -138,18 +160,32 @@ struct ldap_funcs
int (CDECL *ldap_compare_ext_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **);
void (CDECL *ldap_control_free)(LDAPControlU *);
int (CDECL *ldap_count_entries)(void *, void *);
int (CDECL *ldap_count_references)(void *, void *);
int (CDECL *ldap_create_sort_control)(void *, LDAPSortKeyU **, int, LDAPControlU **);
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
int (CDECL *ldap_msgfree)(void *);
char * (CDECL *ldap_next_attribute)(void *, void *, void *);
void * (CDECL *ldap_next_entry)(void *, void *);
void * (CDECL *ldap_next_reference)(void *, void *);
int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
int (CDECL *ldap_result)(void *, int, int, struct timevalU *, void **);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
int (CDECL *ldap_sasl_bind_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, struct bervalU **);
int (CDECL *ldap_sasl_interactive_bind_s)(void *, const char *, const char *, LDAPControlU **, LDAPControlU **,
unsigned int, void *);
int (CDECL *ldap_search_ext)(void *, const char *, int, const char *, char **, int, LDAPControlU **,
LDAPControlU **, struct timevalU *, int, ULONG *);
int (CDECL *ldap_search_ext_s)(void *, const char *, int, const char *, char **, int, LDAPControlU **,
LDAPControlU **, struct timevalU *, int, void **);
int (CDECL *ldap_unbind_ext)(void *, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_unbind_ext_s)(void *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_value_free_len)(struct bervalU **);
......
......@@ -99,7 +99,7 @@ ULONG CDECL ldap_parse_extended_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (!result) return WLDAP32_LDAP_NO_RESULTS_RETURNED;
ret = map_error( ldap_parse_extended_result( ld->ld, result, &oidU, (struct berval **)data, free ) );
ret = map_error( ldap_parse_extended_result( ld->ld, result->Request, &oidU, (struct berval **)data, free ) );
if (oid) {
*oid = strUtoW( oidU );
......@@ -153,18 +153,18 @@ ULONG CDECL ldap_parse_referenceA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *messag
* NOTES
* Free the referrals with ldap_value_free.
*/
ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
PWCHAR **referrals )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP_PARSE_REFERENCE
char **referralsU = NULL;
TRACE( "(%p, %p, %p)\n", ld, message, referrals );
TRACE( "(%p, %p, %p)\n", ld, result, referrals );
if (!ld) return ~0u;
ret = map_error( ldap_parse_reference( ld->ld, message, &referralsU, NULL, 0 ));
ret = map_error( ldap_parse_reference( ld->ld, result->Request, &referralsU, NULL, 0 ));
*referrals = strarrayUtoW( referralsU );
ldap_memfree( referralsU );
......@@ -249,7 +249,7 @@ ULONG CDECL ldap_parse_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
ret = map_error( ldap_parse_result( ld->ld, result, (int *)retcode, &matchedU, &errorU,
ret = map_error( ldap_parse_result( ld->ld, result->Request, (int *)retcode, &matchedU, &errorU,
&referralsU, &serverctrlsU, free ));
if (matched) *matched = strUtoW( matchedU );
......
......@@ -228,7 +228,7 @@ PWCHAR * CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, P
attrU = strWtoU( attr );
if (!attrU) return NULL;
bv = ldap_get_values_len( ld->ld, entry, attrU );
bv = ldap_get_values_len( ld->ld, entry->Request, attrU );
if (bv)
{
retU = bv2str_array( bv );
......@@ -305,7 +305,7 @@ struct WLDAP32_berval ** CDECL ldap_get_values_lenW( WLDAP32_LDAP *ld,
attrU = strWtoU( attr );
if (!attrU) return NULL;
ret = ldap_get_values_len( ld->ld, message, attrU );
ret = ldap_get_values_len( ld->ld, message->Request, attrU );
strfreeU( attrU );
return (struct WLDAP32_berval **)ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment