2005-08-29 11:33:16 +02: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-08-29 11:33:16 +02: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-08-29 11:33:16 +02:00
|
|
|
|
2011-09-05 17:23:34 +02:00
|
|
|
#include "wine/debug.h"
|
2021-04-15 12:20:07 +02:00
|
|
|
#include "winldap_private.h"
|
2005-08-29 11:33:16 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
|
|
|
|
2005-12-31 13:33:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_close_extended_op (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Close an extended operation.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* msgid [I] Message ID of the operation to be closed.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Contrary to native, OpenLDAP does not require us to close
|
|
|
|
* extended operations, so this is a no-op.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_close_extended_op( LDAP *ld, ULONG msgid )
|
2005-08-29 11:33:16 +02:00
|
|
|
{
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, 0x%08x)\n", ld, msgid );
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
|
|
|
return LDAP_SUCCESS;
|
2005-08-29 11:33:16 +02:00
|
|
|
}
|
|
|
|
|
2005-12-31 13:33:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_extended_operationA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_extended_operationW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_extended_operationA( LDAP *ld, char *oid, struct berval *data, LDAPControlA **serverctrls,
|
|
|
|
LDAPControlA **clientctrls, ULONG *message )
|
2005-08-29 11:33:16 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-29 11:33:16 +02:00
|
|
|
WCHAR *oidW = NULL;
|
|
|
|
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
|
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, message );
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !message) return LDAP_PARAM_ERROR;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
if (oid && !(oidW = strAtoW( oid ))) goto exit;
|
|
|
|
if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
|
|
|
|
if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
|
|
|
ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( oidW );
|
2005-08-29 11:33:16 +02:00
|
|
|
controlarrayfreeW( serverctrlsW );
|
|
|
|
controlarrayfreeW( clientctrlsW );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-12-31 13:33:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_extended_operationW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Perform an extended operation (asynchronous mode).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* oid [I] OID of the extended operation.
|
|
|
|
* data [I] Data needed by the operation.
|
|
|
|
* serverctrls [I] Array of LDAP server controls.
|
|
|
|
* clientctrls [I] Array of LDAP client controls.
|
|
|
|
* message [O] Message ID of the extended operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The data parameter should be set to NULL if the operation
|
|
|
|
* requires no data. Call ldap_result with the message ID to
|
|
|
|
* get the result of the operation or ldap_abandon to cancel
|
|
|
|
* the operation. The serverctrls and clientctrls parameters
|
|
|
|
* are optional and should be set to NULL if not used. Call
|
|
|
|
* ldap_close_extended_op to close the operation.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_extended_operationW( LDAP *ld, WCHAR *oid, struct berval *data, LDAPControlW **serverctrls,
|
|
|
|
LDAPControlW **clientctrls, ULONG *message )
|
2005-08-29 11:33:16 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-29 11:33:16 +02:00
|
|
|
char *oidU = NULL;
|
2021-04-15 12:20:07 +02:00
|
|
|
LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
|
|
|
|
struct bervalU *dataU = NULL;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, message );
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !message) return LDAP_PARAM_ERROR;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
if (oid && !(oidU = strWtoU( oid ))) goto exit;
|
|
|
|
if (data && !(dataU = bervalWtoU( data ))) goto exit;
|
|
|
|
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
|
|
|
|
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
ret = map_error( ldap_funcs->fn_ldap_extended_operation( CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU,
|
|
|
|
message ) );
|
2005-08-29 11:33:16 +02:00
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( oidU );
|
2021-04-15 12:20:07 +02:00
|
|
|
bvfreeU( dataU );
|
2005-08-29 11:33:16 +02:00
|
|
|
controlarrayfreeU( serverctrlsU );
|
|
|
|
controlarrayfreeU( clientctrlsU );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-12-31 13:33:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_extended_operation_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_extended_operation_sW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_extended_operation_sA( LDAP *ld, char *oid, struct berval *data, LDAPControlA **serverctrls,
|
|
|
|
LDAPControlA **clientctrls, char **retoid, struct berval **retdata )
|
2005-08-29 11:33:16 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-29 11:33:16 +02:00
|
|
|
WCHAR *oidW = NULL, *retoidW = NULL;
|
|
|
|
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
|
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, retoid, retdata );
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
if (oid && !(oidW = strAtoW( oid ))) goto exit;
|
|
|
|
if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
|
|
|
|
if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW, &retoidW, retdata );
|
|
|
|
if (retoid && retoidW)
|
|
|
|
{
|
|
|
|
char *str = strWtoA( retoidW );
|
|
|
|
if (str) *retoid = str;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
2005-08-29 11:33:16 +02:00
|
|
|
ldap_memfreeW( retoidW );
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( oidW );
|
2005-08-29 11:33:16 +02:00
|
|
|
controlarrayfreeW( serverctrlsW );
|
|
|
|
controlarrayfreeW( clientctrlsW );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-12-31 13:33:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_extended_operation_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Perform an extended operation (synchronous mode).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* oid [I] OID of the extended operation.
|
|
|
|
* data [I] Data needed by the operation.
|
|
|
|
* serverctrls [I] Array of LDAP server controls.
|
|
|
|
* clientctrls [I] Array of LDAP client controls.
|
|
|
|
* retoid [O] OID of the server response message.
|
|
|
|
* retdata [O] Data returned by the server.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The data parameter should be set to NULL if the operation
|
|
|
|
* requires no data. The serverctrls, clientctrls, retoid and
|
|
|
|
* and retdata parameters are also optional. Set to NULL if not
|
|
|
|
* used. Free retoid and retdata after use with ldap_memfree.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_extended_operation_sW( LDAP *ld, WCHAR *oid, struct berval *data, LDAPControlW **serverctrls,
|
|
|
|
LDAPControlW **clientctrls, WCHAR **retoid, struct berval **retdata )
|
2005-08-29 11:33:16 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-29 11:33:16 +02:00
|
|
|
char *oidU = NULL, *retoidU = NULL;
|
2021-04-15 12:20:07 +02:00
|
|
|
LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
|
|
|
|
struct bervalU *retdataU, *dataU = NULL;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, retoid, retdata );
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
2005-08-29 11:33:16 +02:00
|
|
|
|
2021-04-15 12:20:07 +02:00
|
|
|
if (oid && !(oidU = strWtoU( oid ))) goto exit;
|
|
|
|
if (data && !(dataU = bervalWtoU( data ))) goto exit;
|
|
|
|
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
|
|
|
|
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
ret = map_error( ldap_funcs->fn_ldap_extended_operation_s( CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU,
|
|
|
|
&retoidU, &retdataU ) );
|
2021-04-15 12:20:07 +02:00
|
|
|
if (retoid && retoidU)
|
|
|
|
{
|
|
|
|
WCHAR *str = strUtoW( retoidU );
|
|
|
|
if (str) *retoid = str;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
|
|
|
ldap_funcs->fn_ldap_memfree( retoidU );
|
2005-08-29 11:33:16 +02:00
|
|
|
}
|
2021-04-15 12:20:07 +02:00
|
|
|
if (retdata && retdataU)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
struct berval *bv = bervalUtoW( retdataU );
|
2021-04-15 12:20:07 +02:00
|
|
|
if (bv) *retdata = bv;
|
2021-04-19 10:04:54 +02:00
|
|
|
else ret = LDAP_NO_MEMORY;
|
|
|
|
ldap_funcs->fn_ber_bvfree( retdataU );
|
2005-08-29 11:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( oidU );
|
2021-04-15 12:20:07 +02:00
|
|
|
bvfreeU( dataU );
|
2005-08-29 11:33:16 +02:00
|
|
|
controlarrayfreeU( serverctrlsU );
|
|
|
|
controlarrayfreeU( clientctrlsU );
|
|
|
|
return ret;
|
|
|
|
}
|