2005-12-31 13:34:19 +01: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-12-31 13:34:19 +01: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
|
|
|
|
#ifndef LDAP_MAXINT
|
|
|
|
#define LDAP_MAXINT 2147483647
|
|
|
|
#endif
|
2005-12-31 13:34:19 +01: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"
|
2006-04-11 19:49:28 +02:00
|
|
|
|
2005-12-31 13:34:19 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
|
|
|
|
2020-04-17 11:12:02 +02:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
static struct berval null_cookie = { 0, NULL };
|
|
|
|
#endif
|
|
|
|
|
2005-12-31 13:34:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_create_page_controlA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_create_page_controlW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_create_page_controlA( WLDAP32_LDAP *ld, ULONG pagesize,
|
2005-12-31 13:34:19 +01:00
|
|
|
struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlA *control )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPControlW *controlW = NULL;
|
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie,
|
2005-12-31 13:34:19 +01:00
|
|
|
critical, control );
|
|
|
|
|
2006-04-11 19:49:28 +02:00
|
|
|
if (!ld || !control || pagesize > LDAP_MAXINT)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
2005-12-31 13:34:19 +01:00
|
|
|
|
|
|
|
ret = ldap_create_page_controlW( ld, pagesize, cookie, critical, &controlW );
|
|
|
|
if (ret == LDAP_SUCCESS)
|
|
|
|
{
|
|
|
|
*control = controlWtoA( controlW );
|
|
|
|
ldap_control_freeW( controlW );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
|
|
|
|
/* create a page control by hand */
|
|
|
|
static ULONG create_page_control( ULONG pagesize, struct WLDAP32_berval *cookie,
|
|
|
|
UCHAR critical, PLDAPControlW *control )
|
|
|
|
{
|
|
|
|
LDAPControlW *ctrl;
|
|
|
|
BerElement *ber;
|
2006-04-11 19:49:28 +02:00
|
|
|
ber_tag_t tag;
|
2020-04-17 11:12:02 +02:00
|
|
|
struct berval *berval;
|
2005-12-31 13:34:19 +01:00
|
|
|
INT ret, len;
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
ber = ber_alloc_t( LBER_USE_DER );
|
|
|
|
if (!ber) return WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
|
|
|
|
if (cookie)
|
2006-04-11 19:49:28 +02:00
|
|
|
tag = ber_printf( ber, "{iO}", (ber_int_t)pagesize, cookie );
|
2005-12-31 13:34:19 +01:00
|
|
|
else
|
2006-04-11 19:49:28 +02:00
|
|
|
tag = ber_printf( ber, "{iO}", (ber_int_t)pagesize, &null_cookie );
|
2005-12-31 13:34:19 +01:00
|
|
|
|
|
|
|
ret = ber_flatten( ber, &berval );
|
|
|
|
ber_free( ber, 1 );
|
|
|
|
|
2006-04-11 19:49:28 +02:00
|
|
|
if (tag == LBER_ERROR)
|
|
|
|
return WLDAP32_LDAP_ENCODING_ERROR;
|
|
|
|
|
2005-12-31 13:34:19 +01:00
|
|
|
if (ret == -1)
|
|
|
|
return WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
|
|
|
|
/* copy the berval so it can be properly freed by the caller */
|
2018-02-20 12:06:10 +01:00
|
|
|
if (!(val = heap_alloc( berval->bv_len ))) return WLDAP32_LDAP_NO_MEMORY;
|
2005-12-31 13:34:19 +01:00
|
|
|
|
|
|
|
len = berval->bv_len;
|
|
|
|
memcpy( val, berval->bv_val, len );
|
|
|
|
ber_bvfree( berval );
|
|
|
|
|
2018-02-20 12:06:10 +01:00
|
|
|
if (!(ctrl = heap_alloc( sizeof(LDAPControlW) )))
|
2007-02-13 00:02:34 +01:00
|
|
|
{
|
2018-02-20 12:06:10 +01:00
|
|
|
heap_free( val );
|
2005-12-31 13:34:19 +01:00
|
|
|
return WLDAP32_LDAP_NO_MEMORY;
|
2007-02-13 00:02:34 +01:00
|
|
|
}
|
2005-12-31 13:34:19 +01:00
|
|
|
|
|
|
|
ctrl->ldctl_oid = strAtoW( LDAP_PAGED_RESULT_OID_STRING );
|
|
|
|
ctrl->ldctl_value.bv_len = len;
|
|
|
|
ctrl->ldctl_value.bv_val = val;
|
|
|
|
ctrl->ldctl_iscritical = critical;
|
|
|
|
|
|
|
|
*control = ctrl;
|
|
|
|
|
2007-11-08 13:11:34 +01:00
|
|
|
return WLDAP32_LDAP_SUCCESS;
|
2005-12-31 13:34:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_LDAP */
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ldap_create_page_controlW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Create a control for paged search results.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* pagesize [I] Number of entries to return per page.
|
|
|
|
* cookie [I] Used by the server to track its location in the
|
|
|
|
* search results.
|
|
|
|
* critical [I] Tells the server this control is critical to the
|
|
|
|
* search operation.
|
|
|
|
* control [O] LDAPControl created.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_create_page_controlW( WLDAP32_LDAP *ld, ULONG pagesize,
|
2005-12-31 13:34:19 +01:00
|
|
|
struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlW *control )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LDAP
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie,
|
2005-12-31 13:34:19 +01:00
|
|
|
critical, control );
|
|
|
|
|
2006-04-11 19:49:28 +02:00
|
|
|
if (!ld || !control || pagesize > LDAP_MAXINT)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
2005-12-31 13:34:19 +01:00
|
|
|
return create_page_control( pagesize, cookie, critical, control );
|
|
|
|
|
2007-07-23 22:25:50 +02:00
|
|
|
#else
|
2007-11-08 13:11:34 +01:00
|
|
|
return WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_get_next_page( WLDAP32_LDAP *ld, PLDAPSearch search, ULONG pagesize,
|
2005-12-31 13:34:19 +01:00
|
|
|
ULONG *message )
|
|
|
|
{
|
2006-09-30 12:07:23 +02:00
|
|
|
FIXME( "(%p, %p, 0x%08x, %p)\n", ld, search, pagesize, message );
|
2005-12-31 13:34:19 +01:00
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2007-11-08 13:11:34 +01:00
|
|
|
return WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_get_next_page_s( WLDAP32_LDAP *ld, PLDAPSearch search,
|
2005-12-31 13:34:19 +01:00
|
|
|
struct l_timeval *timeout, ULONG pagesize, ULONG *count,
|
|
|
|
WLDAP32_LDAPMessage **results )
|
|
|
|
{
|
2020-04-17 11:12:04 +02:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
ULONG ret;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %u, %p, %p)\n", ld, search, timeout,
|
2005-12-31 13:34:19 +01:00
|
|
|
pagesize, count, results );
|
2020-04-17 11:12:04 +02:00
|
|
|
if (!ld || !search || !count || !results) return ~0u;
|
2005-12-31 13:34:19 +01:00
|
|
|
|
2020-04-17 11:12:04 +02:00
|
|
|
if (search->cookie && search->cookie->bv_len == 0)
|
|
|
|
{
|
|
|
|
/* end of paged results */
|
2020-04-20 07:59:38 +02:00
|
|
|
*count = 0;
|
|
|
|
*results = NULL;
|
2020-04-17 11:12:04 +02:00
|
|
|
return WLDAP32_LDAP_NO_RESULTS_RETURNED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (search->serverctrls[0])
|
|
|
|
{
|
|
|
|
controlfreeW( search->serverctrls[0] );
|
|
|
|
search->serverctrls[0] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("search->cookie: %s\n", search->cookie ? debugstr_an(search->cookie->bv_val, search->cookie->bv_len) : "NULL");
|
|
|
|
ret = ldap_create_page_controlW( ld, pagesize, (struct WLDAP32_berval *)search->cookie, 1, &search->serverctrls[0] );
|
|
|
|
if (ret != WLDAP32_LDAP_SUCCESS) return ret;
|
|
|
|
|
|
|
|
ret = ldap_search_ext_sW( ld, search->dn, search->scope,
|
|
|
|
search->filter, search->attrs, search->attrsonly,
|
|
|
|
search->serverctrls, search->clientctrls,
|
|
|
|
search->timeout.tv_sec ? &search->timeout : NULL, search->sizelimit, results );
|
|
|
|
if (ret != WLDAP32_LDAP_SUCCESS) return ret;
|
|
|
|
|
|
|
|
return ldap_get_paged_count( ld, search, count, *results );
|
|
|
|
|
|
|
|
#endif
|
2007-11-08 13:11:34 +01:00
|
|
|
return WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_get_paged_count( WLDAP32_LDAP *ld, PLDAPSearch search,
|
2005-12-31 13:34:19 +01:00
|
|
|
ULONG *count, WLDAP32_LDAPMessage *results )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LDAP
|
2020-04-17 11:12:02 +02:00
|
|
|
ULONG ret;
|
|
|
|
LDAPControlW **server_ctrls = NULL;
|
2005-12-31 13:34:19 +01:00
|
|
|
|
2020-04-17 11:12:02 +02:00
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, search, count, results );
|
|
|
|
|
|
|
|
if (!ld || !count || !results) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
*count = 0;
|
|
|
|
|
|
|
|
ret = ldap_parse_resultW( ld, results, NULL, NULL, NULL, NULL, &server_ctrls, 0 );
|
|
|
|
if (ret != WLDAP32_LDAP_SUCCESS) return ret;
|
|
|
|
|
|
|
|
if (!server_ctrls) /* assume end of paged results */
|
|
|
|
{
|
|
|
|
search->cookie = &null_cookie;
|
|
|
|
return WLDAP32_LDAP_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (search->cookie)
|
|
|
|
{
|
|
|
|
ber_bvfree( search->cookie );
|
|
|
|
search->cookie = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ldap_parse_page_controlW( ld, server_ctrls, count, (struct WLDAP32_berval **)&search->cookie );
|
|
|
|
if (ret == WLDAP32_LDAP_SUCCESS)
|
|
|
|
TRACE("new search->cookie: %s, count %u\n", debugstr_an(search->cookie->bv_val, search->cookie->bv_len), *count);
|
|
|
|
|
|
|
|
ldap_controls_freeW( server_ctrls );
|
2005-12-31 13:34:19 +01:00
|
|
|
|
|
|
|
return ret;
|
2020-04-17 11:12:02 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
return WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
}
|
|
|
|
|
2006-01-03 12:10:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_page_controlA (WLDAP32.@)
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_page_controlA( WLDAP32_LDAP *ld, PLDAPControlA *ctrls,
|
2005-12-31 13:34:19 +01:00
|
|
|
ULONG *count, struct WLDAP32_berval **cookie )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPControlW **ctrlsW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie );
|
|
|
|
|
|
|
|
if (!ld || !ctrls || !count || !cookie)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
ctrlsW = controlarrayAtoW( ctrls );
|
|
|
|
if (!ctrlsW) return WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
|
|
|
|
ret = ldap_parse_page_controlW( ld, ctrlsW, count, cookie );
|
|
|
|
controlarrayfreeW( ctrlsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-03 12:10:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_page_controlW (WLDAP32.@)
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_page_controlW( WLDAP32_LDAP *ld, PLDAPControlW *ctrls,
|
2005-12-31 13:34:19 +01:00
|
|
|
ULONG *count, struct WLDAP32_berval **cookie )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-31 13:34:19 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPControlW *control = NULL;
|
|
|
|
BerElement *ber;
|
|
|
|
ber_tag_t tag;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie );
|
|
|
|
|
|
|
|
if (!ld || !ctrls || !count || !cookie)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
|
|
|
for (i = 0; ctrls[i]; i++)
|
|
|
|
{
|
|
|
|
if (!lstrcmpW( LDAP_PAGED_RESULT_OID_STRING_W, ctrls[i]->ldctl_oid ))
|
|
|
|
control = ctrls[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!control)
|
|
|
|
return WLDAP32_LDAP_CONTROL_NOT_FOUND;
|
|
|
|
|
|
|
|
ber = ber_init( &((LDAPControl *)control)->ldctl_value );
|
|
|
|
if (!ber)
|
|
|
|
return WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
|
|
|
|
tag = ber_scanf( ber, "{iO}", count, cookie );
|
|
|
|
if ( tag == LBER_ERROR )
|
|
|
|
ret = WLDAP32_LDAP_DECODING_ERROR;
|
|
|
|
else
|
2007-11-08 13:11:34 +01:00
|
|
|
ret = WLDAP32_LDAP_SUCCESS;
|
2005-12-31 13:34:19 +01:00
|
|
|
|
|
|
|
ber_free( ber, 1 );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_search_abandon_page( WLDAP32_LDAP *ld, PLDAPSearch search )
|
2005-12-31 13:34:19 +01:00
|
|
|
{
|
2020-04-17 11:11:57 +02:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPControlW **ctrls;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p)\n", ld, search );
|
|
|
|
|
|
|
|
if (!ld || !search) return ~0u;
|
|
|
|
|
|
|
|
strfreeW( search->dn );
|
|
|
|
strfreeW( search->filter );
|
|
|
|
strarrayfreeW( search->attrs );
|
|
|
|
ctrls = search->serverctrls;
|
|
|
|
controlfreeW( ctrls[0] ); /* page control */
|
|
|
|
ctrls++;
|
|
|
|
while (*ctrls) controlfreeW( *ctrls++ );
|
|
|
|
heap_free( search->serverctrls );
|
|
|
|
controlarrayfreeW( search->clientctrls );
|
2020-04-17 11:12:02 +02:00
|
|
|
if (search->cookie && search->cookie != &null_cookie)
|
2020-04-17 11:11:57 +02:00
|
|
|
ber_bvfree( search->cookie );
|
|
|
|
heap_free( search );
|
2005-12-31 13:34:19 +01:00
|
|
|
|
2007-11-08 13:11:34 +01:00
|
|
|
return WLDAP32_LDAP_SUCCESS;
|
2020-04-17 11:11:57 +02:00
|
|
|
|
|
|
|
#else
|
|
|
|
return WLDAP32_LDAP_NOT_SUPPORTED;
|
|
|
|
#endif
|
2005-12-31 13:34:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-12 21:34:46 +02:00
|
|
|
PLDAPSearch CDECL ldap_search_init_pageA( WLDAP32_LDAP *ld, PCHAR dn, ULONG scope,
|
2005-12-31 13:34:19 +01:00
|
|
|
PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
|
|
|
|
PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyA *sortkeys )
|
|
|
|
{
|
2006-09-30 12:07:23 +02:00
|
|
|
FIXME( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(dn),
|
2005-12-31 13:34:19 +01:00
|
|
|
scope, debugstr_a(filter), attrs, attrsonly );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-06-12 21:34:46 +02:00
|
|
|
PLDAPSearch CDECL ldap_search_init_pageW( WLDAP32_LDAP *ld, PWCHAR dn, ULONG scope,
|
2005-12-31 13:34:19 +01:00
|
|
|
PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
|
|
|
|
PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyW *sortkeys )
|
|
|
|
{
|
2020-04-17 11:11:54 +02:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPSearch *search;
|
|
|
|
DWORD i, len;
|
|
|
|
|
|
|
|
TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
|
|
|
|
ld, debugstr_w(dn), scope, debugstr_w(filter), attrs, attrsonly,
|
|
|
|
serverctrls, clientctrls, timelimit, sizelimit, sortkeys );
|
|
|
|
|
|
|
|
search = heap_alloc_zero( sizeof(*search) );
|
|
|
|
if (!search)
|
|
|
|
{
|
|
|
|
ld->ld_errno = WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dn)
|
|
|
|
{
|
|
|
|
search->dn = strdupW( dn );
|
|
|
|
if (!search->dn) goto fail;
|
|
|
|
}
|
|
|
|
if (filter)
|
|
|
|
{
|
|
|
|
search->filter = strdupW( filter );
|
|
|
|
if (!search->filter) goto fail;
|
|
|
|
}
|
|
|
|
if (attrs)
|
|
|
|
{
|
|
|
|
search->attrs = strarraydupW( attrs );
|
|
|
|
if (!search->attrs) goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = serverctrls ? controlarraylenW( serverctrls ) : 0;
|
|
|
|
search->serverctrls = heap_alloc( sizeof(LDAPControl *) * (len + 2) );
|
|
|
|
if (!search->serverctrls) goto fail;
|
|
|
|
search->serverctrls[0] = NULL; /* reserve 0 for page control */
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
search->serverctrls[i + 1] = controldupW( serverctrls[i] );
|
|
|
|
if (!search->serverctrls[i + 1]) goto fail;
|
|
|
|
}
|
|
|
|
search->serverctrls[len + 1] = NULL;
|
|
|
|
|
|
|
|
if (clientctrls)
|
|
|
|
{
|
|
|
|
search->clientctrls = controlarraydupW( clientctrls );
|
|
|
|
if (!search->clientctrls) goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
search->scope = scope;
|
|
|
|
search->attrsonly = attrsonly;
|
|
|
|
search->timeout.tv_sec = timelimit;
|
|
|
|
search->timeout.tv_usec = 0;
|
|
|
|
search->sizelimit = sizelimit;
|
|
|
|
search->cookie = NULL;
|
|
|
|
|
|
|
|
return search;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
ldap_search_abandon_page( ld, search );
|
|
|
|
ld->ld_errno = WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
|
|
|
|
#endif
|
2005-12-31 13:34:19 +01:00
|
|
|
return NULL;
|
|
|
|
}
|