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 <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
2021-04-19 10:04:54 +02:00
|
|
|
#include "winldap.h"
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2011-09-05 17:23:34 +02:00
|
|
|
#include "wine/debug.h"
|
2021-04-19 10:04:47 +02:00
|
|
|
#include "winldap_private.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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_extended_resultA( LDAP *ld, LDAPMessage *result, char **oid, struct berval **data,
|
|
|
|
BOOLEAN free )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
WCHAR *oidW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, 0x%02x)\n", ld, result, oid, data, free );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
|
|
|
if (!result) return LDAP_NO_RESULTS_RETURNED;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
ret = ldap_parse_extended_resultW( ld, result, &oidW, data, free );
|
2021-04-19 10:04:47 +02:00
|
|
|
if (oid && oidW)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
if ((str = strWtoA( oidW ))) *oid = str;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2005-12-01 18:49:31 +01:00
|
|
|
ldap_memfreeW( oidW );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_extended_resultW (WLDAP32.@)
|
|
|
|
*
|
2021-04-19 10:04:47 +02:00
|
|
|
* Parse the result of an extended operation.
|
2006-08-16 12:53:09 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_extended_resultW( LDAP *ld, LDAPMessage *result, WCHAR **oid, struct berval **data,
|
|
|
|
BOOLEAN free )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
char *oidU = NULL;
|
2021-04-19 10:04:47 +02:00
|
|
|
struct bervalU *dataU = NULL;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p, 0x%02x)\n", ld, result, oid, data, free );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
|
|
|
if (!result) return LDAP_NO_RESULTS_RETURNED;
|
2021-11-04 11:09:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ldap_parse_extended_result_params params = { CTX(ld), result, &oidU, &dataU, free };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_parse_extended_result, ¶ms ));
|
|
|
|
}
|
2021-04-19 10:04:47 +02:00
|
|
|
if (oid && oidU)
|
|
|
|
{
|
|
|
|
WCHAR *str;
|
|
|
|
if ((str = strUtoW( oidU ))) *oid = str;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_memfree, oidU );
|
2021-04-19 10:04:47 +02:00
|
|
|
}
|
|
|
|
if (data && dataU)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
struct berval *bv;
|
2021-04-19 10:04:47 +02:00
|
|
|
if ((bv = bervalUtoW( dataU ))) *data = bv;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ber_bvfree, dataU );
|
2005-12-01 18:49:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_referenceA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_referenceW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_referenceA( LDAP *ld, LDAPMessage *message, char ***referrals )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
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 );
|
2021-04-19 10:04:47 +02:00
|
|
|
if (referralsW)
|
|
|
|
{
|
|
|
|
char **ref;
|
|
|
|
if ((ref = strarrayWtoA( referralsW ))) *referrals = ref;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2021-04-19 10:04:47 +02:00
|
|
|
ldap_value_freeW( referralsW );
|
|
|
|
}
|
2005-12-01 18:49:31 +01:00
|
|
|
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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_referenceW( LDAP *ld, LDAPMessage *message, WCHAR ***referrals )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-11-04 11:09:04 +01:00
|
|
|
ULONG ret = ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
char **referralsU = NULL;
|
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
TRACE( "(%p, %p, %p)\n", ld, message, referrals );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if (ld)
|
|
|
|
{
|
|
|
|
struct ldap_parse_reference_params params = { CTX(ld), message, &referralsU, NULL, 0 };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_parse_reference, ¶ms ));
|
|
|
|
}
|
2021-04-19 10:04:47 +02:00
|
|
|
if (referralsU)
|
|
|
|
{
|
|
|
|
WCHAR **ref;
|
|
|
|
if ((ref = strarrayUtoW( referralsU ))) *referrals = ref;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_memfree, referralsU );
|
2021-04-19 10:04:47 +02:00
|
|
|
}
|
2005-12-01 18:49:31 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_resultA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_parse_resultW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_resultA( LDAP *ld, LDAPMessage *result, ULONG *retcode, char **matched, char **error,
|
|
|
|
char ***referrals, LDAPControlA ***serverctrls, BOOLEAN free )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
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;
|
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p, %p, 0x%02x)\n", ld, result, retcode, matched, error, referrals, serverctrls,
|
|
|
|
free );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
ret = ldap_parse_resultW( ld, result, retcode, &matchedW, &errorW, &referralsW, &serverctrlsW, free );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2008-10-06 15:47:28 +02:00
|
|
|
if (matched) *matched = strWtoA( matchedW );
|
|
|
|
if (error) *error = strWtoA( errorW );
|
|
|
|
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 );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_parse_resultW (WLDAP32.@)
|
|
|
|
*
|
2021-04-19 10:04:47 +02:00
|
|
|
* Parse a result message.
|
2006-08-16 12:53:09 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_resultW( LDAP *ld, LDAPMessage *result, ULONG *retcode, WCHAR **matched, WCHAR **error,
|
|
|
|
WCHAR ***referrals, LDAPControlW ***serverctrls, BOOLEAN free )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
2008-10-06 15:47:28 +02:00
|
|
|
char *matchedU = NULL, *errorU = NULL, **referralsU = NULL;
|
2021-04-19 10:04:47 +02:00
|
|
|
LDAPControlU **serverctrlsU = NULL;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p, %p, 0x%02x)\n", ld, result, retcode, matched, error, referrals, serverctrls,
|
|
|
|
free );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if (ld)
|
|
|
|
{
|
|
|
|
struct ldap_parse_result_params params = { CTX(ld), MSG(result), (int *)retcode, &matchedU,
|
|
|
|
&errorU, &referralsU, &serverctrlsU, free };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_parse_result, ¶ms ));
|
|
|
|
}
|
|
|
|
else return LDAP_PARAM_ERROR;
|
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 );
|
|
|
|
if (referrals) *referrals = strarrayUtoW( referralsU );
|
|
|
|
if (serverctrls) *serverctrls = controlarrayUtoW( serverctrlsU );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_memfree, matchedU );
|
|
|
|
LDAP_CALL( ldap_memfree, errorU );
|
|
|
|
LDAP_CALL( ldap_memvfree, referralsU );
|
|
|
|
LDAP_CALL( ldap_controls_free, serverctrlsU );
|
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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_sort_controlA( LDAP *ld, LDAPControlA **control, ULONG *result, char **attr )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
WCHAR *attrW = NULL;
|
|
|
|
LDAPControlW **controlW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, control, result, attr );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
|
|
|
if (!control) return LDAP_CONTROL_NOT_FOUND;
|
|
|
|
if (!(controlW = controlarrayAtoW( control ))) return 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 );
|
|
|
|
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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_parse_sort_controlW( LDAP *ld, LDAPControlW **control, ULONG *result, WCHAR **attr )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
ULONG ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
char *attrU = NULL;
|
2021-04-19 10:04:47 +02:00
|
|
|
LDAPControlU **controlU, *sortcontrol = NULL;
|
|
|
|
int res;
|
2007-11-08 12:35:36 +01:00
|
|
|
unsigned int i;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
|
|
|
TRACE( "(%p, %p, %p, %p)\n", ld, control, result, attr );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
|
|
|
if (!control) return LDAP_CONTROL_NOT_FOUND;
|
|
|
|
if (!(controlU = controlarrayWtoU( control ))) return LDAP_NO_MEMORY;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2007-11-08 12:35:36 +01:00
|
|
|
for (i = 0; controlU[i]; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp( LDAP_SERVER_RESP_SORT_OID, controlU[i]->ldctl_oid ))
|
|
|
|
sortcontrol = controlU[i];
|
|
|
|
}
|
|
|
|
if (!sortcontrol)
|
|
|
|
{
|
|
|
|
controlarrayfreeU( controlU );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_CONTROL_NOT_FOUND;
|
2007-11-08 12:35:36 +01:00
|
|
|
}
|
2021-11-04 11:09:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ldap_parse_sortresponse_control_params params = { CTX(ld), sortcontrol, &res, &attrU };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_parse_sortresponse_control, ¶ms ));
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
if (ret == LDAP_SUCCESS)
|
2007-11-08 12:35:36 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
WCHAR *str;
|
|
|
|
if ((str = strUtoW( attrU )))
|
|
|
|
{
|
|
|
|
*attr = str;
|
|
|
|
*result = res;
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_memfree, attrU );
|
2007-11-08 12:35:36 +01:00
|
|
|
}
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
controlarrayfreeU( controlU );
|
|
|
|
return 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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
int CDECL ldap_parse_vlv_controlA( LDAP *ld, LDAPControlA **control, ULONG *targetpos, ULONG *listcount,
|
|
|
|
struct berval **context, int *errcode )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
int ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
LDAPControlW **controlW = NULL;
|
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p)\n", ld, control, targetpos, listcount, context, errcode );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (control && !(controlW = controlarrayAtoW( control ))) return LDAP_NO_MEMORY;
|
2021-04-19 10:04:47 +02:00
|
|
|
ret = ldap_parse_vlv_controlW( ld, controlW, targetpos, listcount, context, errcode );
|
2005-12-01 18:49:31 +01:00
|
|
|
controlarrayfreeW( controlW );
|
|
|
|
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.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
int CDECL ldap_parse_vlv_controlW( LDAP *ld, LDAPControlW **control, ULONG *targetpos, ULONG *listcount,
|
|
|
|
struct berval **context, int *errcode )
|
2005-12-01 18:49:31 +01:00
|
|
|
{
|
2021-04-19 10:04:47 +02:00
|
|
|
int ret, pos, count;
|
|
|
|
LDAPControlU **controlU, *vlvcontrolU = NULL;
|
|
|
|
struct bervalU *ctxU;
|
2007-11-08 12:35:36 +01:00
|
|
|
unsigned int i;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
TRACE( "(%p, %p, %p, %p, %p, %p)\n", ld, control, targetpos, listcount, context, errcode );
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld || !control) return ~0u;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!(controlU = controlarrayWtoU( control ))) return LDAP_NO_MEMORY;
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2007-11-08 12:35:36 +01:00
|
|
|
for (i = 0; controlU[i]; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp( LDAP_CONTROL_VLVRESPONSE, controlU[i]->ldctl_oid ))
|
2021-04-19 10:04:47 +02:00
|
|
|
vlvcontrolU = controlU[i];
|
2007-11-08 12:35:36 +01:00
|
|
|
}
|
2021-04-19 10:04:47 +02:00
|
|
|
if (!vlvcontrolU)
|
2007-11-08 12:35:36 +01:00
|
|
|
{
|
|
|
|
controlarrayfreeU( controlU );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_CONTROL_NOT_FOUND;
|
2007-11-08 12:35:36 +01:00
|
|
|
}
|
2021-11-04 11:09:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ldap_parse_vlvresponse_control_params params = { CTX(ld), vlvcontrolU, &pos, &count, &ctxU, errcode };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_parse_vlvresponse_control, ¶ms ));
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
if (ret == LDAP_SUCCESS)
|
2007-11-08 12:35:36 +01:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
struct berval *bv;
|
2021-04-19 10:04:47 +02:00
|
|
|
if ((bv = bervalUtoW( ctxU )))
|
|
|
|
{
|
|
|
|
*context = bv;
|
|
|
|
*targetpos = pos;
|
|
|
|
*listcount = count;
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ber_bvfree, ctxU );
|
2007-11-08 12:35:36 +01:00
|
|
|
}
|
2005-12-01 18:49:31 +01:00
|
|
|
|
2021-04-19 10:04:47 +02:00
|
|
|
controlarrayfreeU( controlU );
|
|
|
|
return ret;
|
2005-12-01 18:49:31 +01:00
|
|
|
}
|