2005-12-01 18:49:31 +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-01 18:49:31 +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
|
2005-12-01 18:49:31 +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"
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_extended_resultA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_extended_resultW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_extended_resultA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
|
2005-12-01 18:49:31 +01:00
|
|
|
PCHAR *oid, struct WLDAP32_berval **data, BOOLEAN free )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
WCHAR *oidW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, 0x%02x)\n", ld, result, oid, data, free );
|
|
|
|
|
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
if (!result) return WLDAP32_LDAP_NO_RESULTS_RETURNED;
|
|
|
|
|
|
|
|
ret = ldap_parse_extended_resultW( ld, result, &oidW, data, free );
|
|
|
|
|
|
|
|
if (oid) {
|
|
|
|
*oid = strWtoA( oidW );
|
|
|
|
if (!*oid) ret = WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
ldap_memfreeW( oidW );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_extended_resultW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Parse the result of an extended operation.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* result [I] Result message from an extended operation.
|
|
|
|
* oid [O] OID of the extended operation.
|
|
|
|
* data [O] Result data.
|
|
|
|
* free [I] Free the result message?
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Free the OID and result data with ldap_memfree. Pass a nonzero
|
|
|
|
* value for 'free' or call ldap_msgfree to free the result message.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_extended_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
|
2005-12-01 18:49:31 +01:00
|
|
|
PWCHAR *oid, struct WLDAP32_berval **data, BOOLEAN free )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
char *oidU = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, 0x%02x)\n", ld, result, oid, data, free );
|
|
|
|
|
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
if (!result) return WLDAP32_LDAP_NO_RESULTS_RETURNED;
|
|
|
|
|
2008-10-20 12:22:13 +02:00
|
|
|
ret = map_error( ldap_parse_extended_result( ld, result, &oidU, (struct berval **)data, free ) );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
if (oid) {
|
|
|
|
*oid = strUtoW( oidU );
|
|
|
|
if (!*oid) ret = WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
ldap_memfree( oidU );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_referenceA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_referenceW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_referenceA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
|
2005-12-01 18:49:31 +01:00
|
|
|
PCHAR **referrals )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
WCHAR **referralsW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p)\n", ld, message, referrals );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
ret = ldap_parse_referenceW( ld, message, &referralsW );
|
|
|
|
|
|
|
|
*referrals = strarrayWtoA( referralsW );
|
|
|
|
ldap_value_freeW( referralsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_referenceW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Return any referrals from a result message.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* result [I] Result message.
|
|
|
|
* referrals [O] Array of referral URLs.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Free the referrals with ldap_value_free.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
|
2005-12-01 18:49:31 +01:00
|
|
|
PWCHAR **referrals )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-21 18:42:00 +01:00
|
|
|
#ifdef HAVE_LDAP_PARSE_REFERENCE
|
2005-12-01 18:49:31 +01:00
|
|
|
char **referralsU = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p)\n", ld, message, referrals );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-20 12:22:13 +02:00
|
|
|
ret = map_error( ldap_parse_reference( ld, message, &referralsU, NULL, 0 ));
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
*referrals = strarrayUtoW( referralsU );
|
|
|
|
ldap_memfree( referralsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_resultA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_resultW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_resultA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
|
2005-12-01 18:49:31 +01:00
|
|
|
ULONG *retcode, PCHAR *matched, PCHAR *error, PCHAR **referrals,
|
|
|
|
PLDAPControlA **serverctrls, BOOLEAN free )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
2008-10-06 15:47:28 +02:00
|
|
|
WCHAR *matchedW = NULL, *errorW = NULL, **referralsW = NULL;
|
2005-12-01 18:49:31 +01:00
|
|
|
LDAPControlW **serverctrlsW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p, %p, 0x%02x)\n", ld, result, retcode,
|
|
|
|
matched, error, referrals, serverctrls, free );
|
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
ret = ldap_parse_resultW( ld, result, retcode, &matchedW, &errorW,
|
2005-12-01 18:49:31 +01:00
|
|
|
&referralsW, &serverctrlsW, free );
|
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (matched) *matched = strWtoA( matchedW );
|
|
|
|
if (error) *error = strWtoA( errorW );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (referrals) *referrals = strarrayWtoA( referralsW );
|
|
|
|
if (serverctrls) *serverctrls = controlarrayWtoA( serverctrlsW );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
ldap_memfreeW( matchedW );
|
|
|
|
ldap_memfreeW( errorW );
|
2005-12-01 18:49:31 +01:00
|
|
|
ldap_value_freeW( referralsW );
|
|
|
|
ldap_controls_freeW( serverctrlsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_resultW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Parse a result message.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* result [I] Result message.
|
|
|
|
* retcode [O] Return code for the server operation.
|
|
|
|
* matched [O] DNs matched in the operation.
|
|
|
|
* error [O] Error message for the operation.
|
|
|
|
* referrals [O] Referrals found in the result message.
|
|
|
|
* serverctrls [O] Controls used in the operation.
|
|
|
|
* free [I] Free the result message?
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Free the DNs and error message with ldap_memfree. Free
|
|
|
|
* the referrals with ldap_value_free and the controls with
|
|
|
|
* ldap_controls_free. Pass a nonzero value for 'free' or call
|
|
|
|
* ldap_msgfree to free the result message.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
|
2005-12-01 18:49:31 +01:00
|
|
|
ULONG *retcode, PWCHAR *matched, PWCHAR *error, PWCHAR **referrals,
|
|
|
|
PLDAPControlW **serverctrls, BOOLEAN free )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
2008-10-06 15:47:28 +02:00
|
|
|
char *matchedU = NULL, *errorU = NULL, **referralsU = NULL;
|
2005-12-01 18:49:31 +01:00
|
|
|
LDAPControl **serverctrlsU = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p, %p, 0x%02x)\n", ld, result, retcode,
|
|
|
|
matched, error, referrals, serverctrls, free );
|
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-20 12:22:13 +02:00
|
|
|
ret = map_error( ldap_parse_result( ld, result, (int *)retcode, &matchedU, &errorU,
|
|
|
|
&referralsU, &serverctrlsU, free ));
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (matched) *matched = strUtoW( matchedU );
|
|
|
|
if (error) *error = strUtoW( errorU );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (referrals) *referrals = strarrayUtoW( referralsU );
|
|
|
|
if (serverctrls) *serverctrls = controlarrayUtoW( serverctrlsU );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
ldap_memfree( matchedU );
|
|
|
|
ldap_memfree( errorU );
|
2008-10-06 15:47:28 +02:00
|
|
|
strarrayfreeU( referralsU );
|
2005-12-01 18:49:31 +01:00
|
|
|
ldap_controls_free( serverctrlsU );
|
|
|
|
|
|
|
|
#endif
|
2008-10-20 12:22:13 +02:00
|
|
|
return ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_sort_controlA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_sort_controlW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_sort_controlA( WLDAP32_LDAP *ld, PLDAPControlA *control,
|
2005-12-01 18:49:31 +01:00
|
|
|
ULONG *result, PCHAR *attr )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
WCHAR *attrW = NULL;
|
|
|
|
LDAPControlW **controlW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, control, result, attr );
|
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
if (!control) return WLDAP32_LDAP_CONTROL_NOT_FOUND;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
controlW = controlarrayAtoW( control );
|
|
|
|
if (!controlW) return WLDAP32_LDAP_NO_MEMORY;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
ret = ldap_parse_sort_controlW( ld, controlW, result, &attrW );
|
|
|
|
|
|
|
|
*attr = strWtoA( attrW );
|
|
|
|
controlarrayfreeW( controlW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_sort_controlW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Parse a sort control.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* control [I] Control obtained from a result message.
|
|
|
|
* result [O] Result code.
|
|
|
|
* attr [O] Failing attribute.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* If the function fails, free the failing attribute with ldap_memfree.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_parse_sort_controlW( WLDAP32_LDAP *ld, PLDAPControlW *control,
|
2005-12-01 18:49:31 +01:00
|
|
|
ULONG *result, PWCHAR *attr )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
char *attrU = NULL;
|
|
|
|
LDAPControl **controlU = NULL;
|
2007-11-08 12:35:36 +01:00
|
|
|
#ifdef HAVE_LDAP_PARSE_SORT_CONTROL
|
2006-09-30 12:07:23 +02:00
|
|
|
unsigned long res;
|
2007-11-08 12:35:36 +01:00
|
|
|
#elif defined(HAVE_LDAP_PARSE_SORTRESPONSE_CONTROL)
|
|
|
|
ber_int_t res;
|
|
|
|
LDAPControl *sortcontrol = NULL;
|
|
|
|
unsigned int i;
|
|
|
|
#endif
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, control, result, attr );
|
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
if (!control) return WLDAP32_LDAP_CONTROL_NOT_FOUND;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:46:54 +02:00
|
|
|
controlU = controlarrayWtoU( control );
|
|
|
|
if (!controlU) return WLDAP32_LDAP_NO_MEMORY;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2007-11-08 12:35:36 +01:00
|
|
|
#ifdef HAVE_LDAP_PARSE_SORT_CONTROL
|
|
|
|
if (!(ret = ldap_parse_sort_control( ld, controlU, &res, &attrU )))
|
|
|
|
{
|
|
|
|
*result = res;
|
|
|
|
*attr = strUtoW( attrU );
|
|
|
|
}
|
|
|
|
#elif defined(HAVE_LDAP_PARSE_SORTRESPONSE_CONTROL)
|
|
|
|
for (i = 0; controlU[i]; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp( LDAP_SERVER_RESP_SORT_OID, controlU[i]->ldctl_oid ))
|
|
|
|
sortcontrol = controlU[i];
|
|
|
|
}
|
|
|
|
if (!sortcontrol)
|
|
|
|
{
|
|
|
|
controlarrayfreeU( controlU );
|
|
|
|
return WLDAP32_LDAP_CONTROL_NOT_FOUND;
|
|
|
|
}
|
|
|
|
if (!(ret = ldap_parse_sortresponse_control( ld, sortcontrol, &res, &attrU )))
|
|
|
|
{
|
|
|
|
*result = res;
|
|
|
|
*attr = strUtoW( attrU );
|
|
|
|
}
|
|
|
|
#endif
|
2005-12-01 18:49:31 +01:00
|
|
|
controlarrayfreeU( controlU );
|
|
|
|
|
|
|
|
#endif
|
2008-10-06 15:47:28 +02:00
|
|
|
return map_error( ret );
|
2005-12-01 18:49:31 +01:00
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_vlv_controlA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_vlv_controlW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
INT CDECL ldap_parse_vlv_controlA( WLDAP32_LDAP *ld, PLDAPControlA *control,
|
2005-12-02 13:01:07 +01:00
|
|
|
PULONG targetpos, PULONG listcount,
|
|
|
|
struct WLDAP32_berval **context, PINT errcode )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
int ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPControlW **controlW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p)\n", ld, control, targetpos,
|
|
|
|
listcount, context, errcode );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
if (control) {
|
|
|
|
controlW = controlarrayAtoW( control );
|
|
|
|
if (!controlW) return WLDAP32_LDAP_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ldap_parse_vlv_controlW( ld, controlW, targetpos, listcount,
|
|
|
|
context, errcode );
|
|
|
|
|
|
|
|
controlarrayfreeW( controlW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_vlv_controlW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Parse a virtual list view control.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* control [I] Controls obtained from a result message.
|
2008-01-03 00:46:32 +01:00
|
|
|
* targetpos [O] Position of the target in the result list.
|
2006-08-16 12:53:09 +02:00
|
|
|
* listcount [O] Estimate of the number of results in the list.
|
|
|
|
* context [O] Server side context.
|
|
|
|
* errcode [O] Error code from the listview operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Free the server context with ber_bvfree.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
INT CDECL ldap_parse_vlv_controlW( WLDAP32_LDAP *ld, PLDAPControlW *control,
|
2005-12-02 13:01:07 +01:00
|
|
|
PULONG targetpos, PULONG listcount,
|
|
|
|
struct WLDAP32_berval **context, PINT errcode )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
int ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-12-01 18:49:31 +01:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
LDAPControl **controlU = NULL;
|
2007-11-08 12:35:36 +01:00
|
|
|
#ifdef HAVE_LDAP_PARSE_VLV_CONTROL
|
2006-09-30 12:07:23 +02:00
|
|
|
unsigned long pos, count;
|
2007-11-08 12:35:36 +01:00
|
|
|
#elif defined(HAVE_LDAP_PARSE_VLVRESPONSE_CONTROL)
|
|
|
|
ber_int_t pos, count;
|
|
|
|
LDAPControl *vlvcontrol = NULL;
|
|
|
|
unsigned int i;
|
|
|
|
#endif
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p)\n", ld, control, targetpos,
|
|
|
|
listcount, context, errcode );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld || !control) return ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:46:54 +02:00
|
|
|
controlU = controlarrayWtoU( control );
|
|
|
|
if (!controlU) return WLDAP32_LDAP_NO_MEMORY;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2007-11-08 12:35:36 +01:00
|
|
|
#ifdef HAVE_LDAP_PARSE_VLV_CONTROL
|
|
|
|
if (!(ret = ldap_parse_vlv_control( ld, controlU, &pos, &count,
|
2009-01-13 10:54:41 +01:00
|
|
|
context, errcode )))
|
2007-11-08 12:35:36 +01:00
|
|
|
{
|
|
|
|
*targetpos = pos;
|
|
|
|
*listcount = count;
|
|
|
|
}
|
|
|
|
#elif defined(HAVE_LDAP_PARSE_VLVRESPONSE_CONTROL)
|
|
|
|
for (i = 0; controlU[i]; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp( LDAP_CONTROL_VLVRESPONSE, controlU[i]->ldctl_oid ))
|
|
|
|
vlvcontrol = controlU[i];
|
|
|
|
}
|
|
|
|
if (!vlvcontrol)
|
|
|
|
{
|
|
|
|
controlarrayfreeU( controlU );
|
|
|
|
return WLDAP32_LDAP_CONTROL_NOT_FOUND;
|
|
|
|
}
|
|
|
|
if (!(ret = ldap_parse_vlvresponse_control( ld, vlvcontrol, &pos, &count,
|
|
|
|
(struct berval **)context, errcode )))
|
|
|
|
{
|
|
|
|
*targetpos = pos;
|
|
|
|
*listcount = count;
|
|
|
|
}
|
|
|
|
#endif
|
2005-12-01 18:49:31 +01:00
|
|
|
controlarrayfreeU( controlU );
|
|
|
|
|
|
|
|
#endif
|
2008-10-20 12:22:13 +02:00
|
|
|
return map_error( ret );
|
2005-12-01 18:49:31 +01:00
|
|
|
}
|