2005-08-09 22:35:17 +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-09 22:35:17 +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-09 22:35:17 +02:00
|
|
|
|
2011-09-05 17:23:34 +02:00
|
|
|
#include "wine/debug.h"
|
2021-04-16 09:59:17 +02:00
|
|
|
#include "winldap_private.h"
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
#ifndef LDAP_OPT_SERVER_CONTROLS
|
|
|
|
#define LDAP_OPT_SERVER_CONTROLS 0x0012
|
|
|
|
#endif
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_get_optionA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_get_optionW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_get_optionA( LDAP *ld, int option, void *value )
|
2005-08-09 22:35:17 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
ULONG ret;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !value) return LDAP_PARAM_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
switch (option)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_API_FEATURE_INFO:
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
|
|
|
LDAPAPIFeatureInfoW featureW;
|
|
|
|
LDAPAPIFeatureInfoA *featureA = value;
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!featureA->ldapaif_name) return LDAP_PARAM_ERROR;
|
2005-08-12 17:52:13 +02:00
|
|
|
|
|
|
|
featureW.ldapaif_info_version = featureA->ldapaif_info_version;
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!(featureW.ldapaif_name = strAtoW( featureA->ldapaif_name ))) return LDAP_NO_MEMORY;
|
2005-08-12 17:52:13 +02:00
|
|
|
featureW.ldapaif_version = 0;
|
|
|
|
|
|
|
|
ret = ldap_get_optionW( ld, option, &featureW );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (ret == LDAP_SUCCESS) featureA->ldapaif_version = featureW.ldapaif_version;
|
2021-04-19 10:04:52 +02:00
|
|
|
free( featureW.ldapaif_name );
|
2005-08-12 17:52:13 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_API_INFO:
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
|
|
|
LDAPAPIInfoW infoW;
|
|
|
|
LDAPAPIInfoA *infoA = value;
|
|
|
|
|
2021-04-16 09:59:17 +02:00
|
|
|
memset( &infoW, 0, sizeof(infoW) );
|
2005-08-12 17:52:13 +02:00
|
|
|
infoW.ldapai_info_version = infoA->ldapai_info_version;
|
|
|
|
|
|
|
|
ret = ldap_get_optionW( ld, option, &infoW );
|
2021-04-19 10:04:54 +02:00
|
|
|
if (ret == LDAP_SUCCESS)
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
infoA->ldapai_api_version = infoW.ldapai_api_version;
|
|
|
|
infoA->ldapai_protocol_version = infoW.ldapai_protocol_version;
|
|
|
|
|
|
|
|
if (infoW.ldapai_extensions && !(infoA->ldapai_extensions = strarrayWtoA( infoW.ldapai_extensions )))
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NO_MEMORY;
|
2021-04-16 09:59:17 +02:00
|
|
|
if (infoW.ldapai_vendor_name && !(infoA->ldapai_vendor_name = strWtoA( infoW.ldapai_vendor_name )))
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
|
|
|
ldap_value_freeW( infoW.ldapai_extensions );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NO_MEMORY;
|
2005-08-12 17:52:13 +02:00
|
|
|
}
|
2021-04-16 09:59:17 +02:00
|
|
|
infoA->ldapai_vendor_version = infoW.ldapai_vendor_version;
|
2005-08-12 17:52:13 +02:00
|
|
|
|
2021-04-16 09:59:17 +02:00
|
|
|
ldap_value_freeW( infoW.ldapai_extensions );
|
|
|
|
ldap_memfreeW( infoW.ldapai_vendor_name );
|
|
|
|
}
|
2005-08-12 17:52:13 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_DEREF:
|
|
|
|
case LDAP_OPT_DESC:
|
|
|
|
case LDAP_OPT_ERROR_NUMBER:
|
|
|
|
case LDAP_OPT_PROTOCOL_VERSION:
|
|
|
|
case LDAP_OPT_REFERRALS:
|
|
|
|
case LDAP_OPT_SIZELIMIT:
|
|
|
|
case LDAP_OPT_TIMELIMIT:
|
2005-08-09 22:35:17 +02:00
|
|
|
return ldap_get_optionW( ld, option, value );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_CACHE_ENABLE:
|
|
|
|
case LDAP_OPT_CACHE_FN_PTRS:
|
|
|
|
case LDAP_OPT_CACHE_STRATEGY:
|
|
|
|
case LDAP_OPT_IO_FN_PTRS:
|
|
|
|
case LDAP_OPT_REBIND_ARG:
|
|
|
|
case LDAP_OPT_REBIND_FN:
|
|
|
|
case LDAP_OPT_RESTART:
|
|
|
|
case LDAP_OPT_THREAD_FN_PTRS:
|
|
|
|
return LDAP_LOCAL_ERROR;
|
|
|
|
|
|
|
|
case LDAP_OPT_AREC_EXCLUSIVE:
|
|
|
|
case LDAP_OPT_AUTO_RECONNECT:
|
|
|
|
case LDAP_OPT_CLIENT_CERTIFICATE:
|
|
|
|
case LDAP_OPT_DNSDOMAIN_NAME:
|
|
|
|
case LDAP_OPT_ENCRYPT:
|
|
|
|
case LDAP_OPT_ERROR_STRING:
|
|
|
|
case LDAP_OPT_FAST_CONCURRENT_BIND:
|
|
|
|
case LDAP_OPT_GETDSNAME_FLAGS:
|
|
|
|
case LDAP_OPT_HOST_NAME:
|
|
|
|
case LDAP_OPT_HOST_REACHABLE:
|
|
|
|
case LDAP_OPT_PING_KEEP_ALIVE:
|
|
|
|
case LDAP_OPT_PING_LIMIT:
|
|
|
|
case LDAP_OPT_PING_WAIT_TIME:
|
|
|
|
case LDAP_OPT_PROMPT_CREDENTIALS:
|
|
|
|
case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
|
|
|
|
case LDAP_OPT_REFERRAL_CALLBACK:
|
|
|
|
case LDAP_OPT_REFERRAL_HOP_LIMIT:
|
|
|
|
case LDAP_OPT_ROOTDSE_CACHE:
|
|
|
|
case LDAP_OPT_SASL_METHOD:
|
|
|
|
case LDAP_OPT_SECURITY_CONTEXT:
|
|
|
|
case LDAP_OPT_SEND_TIMEOUT:
|
|
|
|
case LDAP_OPT_SERVER_CERTIFICATE:
|
|
|
|
case LDAP_OPT_SERVER_CONTROLS:
|
|
|
|
case LDAP_OPT_SERVER_ERROR:
|
|
|
|
case LDAP_OPT_SERVER_EXT_ERROR:
|
|
|
|
case LDAP_OPT_SIGN:
|
|
|
|
case LDAP_OPT_SSL:
|
|
|
|
case LDAP_OPT_SSL_INFO:
|
|
|
|
case LDAP_OPT_SSPI_FLAGS:
|
|
|
|
case LDAP_OPT_TCP_KEEPALIVE:
|
2005-08-09 22:35:17 +02:00
|
|
|
FIXME( "Unsupported option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NOT_SUPPORTED;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unknown option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_LOCAL_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_get_optionW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Retrieve option values for a given LDAP context.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* option [I] Option to get values for.
|
|
|
|
* value [O] Pointer to option values.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_get_optionW( LDAP *ld, int option, void *value )
|
2005-08-09 22:35:17 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
ULONG ret;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !value) return LDAP_PARAM_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
switch (option)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_API_FEATURE_INFO:
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
LDAPAPIFeatureInfoU featureU;
|
2005-08-12 17:52:13 +02:00
|
|
|
LDAPAPIFeatureInfoW *featureW = value;
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!featureW->ldapaif_name) return LDAP_PARAM_ERROR;
|
2005-08-12 17:52:13 +02:00
|
|
|
|
|
|
|
featureU.ldapaif_info_version = featureW->ldapaif_info_version;
|
2021-11-04 11:09:04 +01:00
|
|
|
if ((featureU.ldapaif_name = strWtoU( featureW->ldapaif_name )))
|
|
|
|
{
|
|
|
|
struct ldap_get_option_params params = { CTX(ld), option, &featureU };
|
|
|
|
featureU.ldapaif_version = 0;
|
|
|
|
ret = map_error( LDAP_CALL( ldap_get_option, ¶ms ));
|
|
|
|
}
|
|
|
|
else return LDAP_NO_MEMORY;
|
2005-08-12 17:52:13 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (ret == LDAP_SUCCESS) featureW->ldapaif_version = featureU.ldapaif_version;
|
2021-04-19 10:04:52 +02:00
|
|
|
free( featureU.ldapaif_name );
|
2005-08-12 17:52:13 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_API_INFO:
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
LDAPAPIInfoU infoU;
|
2005-08-12 17:52:13 +02:00
|
|
|
LDAPAPIInfoW *infoW = value;
|
2021-11-04 11:09:04 +01:00
|
|
|
struct ldap_get_option_params params = { CTX(ld), option, &infoU };
|
2005-08-12 17:52:13 +02:00
|
|
|
|
2021-04-16 09:59:17 +02:00
|
|
|
memset( &infoU, 0, sizeof(infoU) );
|
2005-08-12 17:52:13 +02:00
|
|
|
infoU.ldapai_info_version = infoW->ldapai_info_version;
|
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
ret = map_error( LDAP_CALL( ldap_get_option, ¶ms ));
|
2021-04-19 10:04:54 +02:00
|
|
|
if (ret == LDAP_SUCCESS)
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
infoW->ldapai_api_version = infoU.ldapai_api_version;
|
|
|
|
infoW->ldapai_protocol_version = infoU.ldapai_protocol_version;
|
|
|
|
|
|
|
|
if (infoU.ldapai_extensions && !(infoW->ldapai_extensions = strarrayUtoW( infoU.ldapai_extensions )))
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NO_MEMORY;
|
2021-04-16 09:59:17 +02:00
|
|
|
if (infoU.ldapai_vendor_name && !(infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name )))
|
2005-08-12 17:52:13 +02:00
|
|
|
{
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_memvfree, infoU.ldapai_extensions );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NO_MEMORY;
|
2005-08-12 17:52:13 +02:00
|
|
|
}
|
2021-04-16 09:59:17 +02:00
|
|
|
infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
|
2005-08-12 17:52:13 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_memvfree, infoU.ldapai_extensions );
|
|
|
|
LDAP_CALL( ldap_memfree, infoU.ldapai_vendor_name );
|
2021-04-16 09:59:17 +02:00
|
|
|
}
|
2005-08-12 17:52:13 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_DEREF:
|
|
|
|
case LDAP_OPT_DESC:
|
|
|
|
case LDAP_OPT_ERROR_NUMBER:
|
|
|
|
case LDAP_OPT_PROTOCOL_VERSION:
|
|
|
|
case LDAP_OPT_REFERRALS:
|
|
|
|
case LDAP_OPT_SIZELIMIT:
|
|
|
|
case LDAP_OPT_TIMELIMIT:
|
2021-11-04 11:09:04 +01:00
|
|
|
{
|
|
|
|
struct ldap_get_option_params params = { CTX(ld), option, value };
|
|
|
|
return map_error( LDAP_CALL( ldap_get_option, ¶ms ));
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
|
|
|
|
case LDAP_OPT_CACHE_ENABLE:
|
|
|
|
case LDAP_OPT_CACHE_FN_PTRS:
|
|
|
|
case LDAP_OPT_CACHE_STRATEGY:
|
|
|
|
case LDAP_OPT_IO_FN_PTRS:
|
|
|
|
case LDAP_OPT_REBIND_ARG:
|
|
|
|
case LDAP_OPT_REBIND_FN:
|
|
|
|
case LDAP_OPT_RESTART:
|
|
|
|
case LDAP_OPT_THREAD_FN_PTRS:
|
|
|
|
return LDAP_LOCAL_ERROR;
|
|
|
|
|
|
|
|
case LDAP_OPT_AREC_EXCLUSIVE:
|
|
|
|
case LDAP_OPT_AUTO_RECONNECT:
|
|
|
|
case LDAP_OPT_CLIENT_CERTIFICATE:
|
|
|
|
case LDAP_OPT_DNSDOMAIN_NAME:
|
|
|
|
case LDAP_OPT_ENCRYPT:
|
|
|
|
case LDAP_OPT_ERROR_STRING:
|
|
|
|
case LDAP_OPT_FAST_CONCURRENT_BIND:
|
|
|
|
case LDAP_OPT_GETDSNAME_FLAGS:
|
|
|
|
case LDAP_OPT_HOST_NAME:
|
|
|
|
case LDAP_OPT_HOST_REACHABLE:
|
|
|
|
case LDAP_OPT_PING_KEEP_ALIVE:
|
|
|
|
case LDAP_OPT_PING_LIMIT:
|
|
|
|
case LDAP_OPT_PING_WAIT_TIME:
|
|
|
|
case LDAP_OPT_PROMPT_CREDENTIALS:
|
|
|
|
case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
|
|
|
|
case LDAP_OPT_REFERRAL_CALLBACK:
|
|
|
|
case LDAP_OPT_REFERRAL_HOP_LIMIT:
|
|
|
|
case LDAP_OPT_ROOTDSE_CACHE:
|
|
|
|
case LDAP_OPT_SASL_METHOD:
|
|
|
|
case LDAP_OPT_SECURITY_CONTEXT:
|
|
|
|
case LDAP_OPT_SEND_TIMEOUT:
|
|
|
|
case LDAP_OPT_SERVER_CERTIFICATE:
|
|
|
|
case LDAP_OPT_SERVER_CONTROLS:
|
|
|
|
case LDAP_OPT_SERVER_ERROR:
|
|
|
|
case LDAP_OPT_SERVER_EXT_ERROR:
|
|
|
|
case LDAP_OPT_SIGN:
|
|
|
|
case LDAP_OPT_SSL:
|
|
|
|
case LDAP_OPT_SSL_INFO:
|
|
|
|
case LDAP_OPT_SSPI_FLAGS:
|
|
|
|
case LDAP_OPT_TCP_KEEPALIVE:
|
2005-08-09 22:35:17 +02:00
|
|
|
FIXME( "Unsupported option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NOT_SUPPORTED;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unknown option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_LOCAL_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_set_optionA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_set_optionW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_set_optionA( LDAP *ld, int option, void *value )
|
2005-08-09 22:35:17 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
ULONG ret;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
switch (option)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_SERVER_CONTROLS:
|
2006-08-16 12:53:21 +02:00
|
|
|
{
|
|
|
|
LDAPControlW **ctrlsW;
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!(ctrlsW = controlarrayAtoW( value ))) return LDAP_NO_MEMORY;
|
2006-08-16 12:53:21 +02:00
|
|
|
ret = ldap_set_optionW( ld, option, ctrlsW );
|
|
|
|
controlarrayfreeW( ctrlsW );
|
|
|
|
return ret;
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_DEREF:
|
|
|
|
case LDAP_OPT_DESC:
|
|
|
|
case LDAP_OPT_ERROR_NUMBER:
|
|
|
|
case LDAP_OPT_PROTOCOL_VERSION:
|
|
|
|
case LDAP_OPT_REFERRALS:
|
|
|
|
case LDAP_OPT_SIZELIMIT:
|
|
|
|
case LDAP_OPT_TIMELIMIT:
|
2005-08-09 22:35:17 +02:00
|
|
|
return ldap_set_optionW( ld, option, value );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_CACHE_ENABLE:
|
|
|
|
case LDAP_OPT_CACHE_FN_PTRS:
|
|
|
|
case LDAP_OPT_CACHE_STRATEGY:
|
|
|
|
case LDAP_OPT_IO_FN_PTRS:
|
|
|
|
case LDAP_OPT_REBIND_ARG:
|
|
|
|
case LDAP_OPT_REBIND_FN:
|
|
|
|
case LDAP_OPT_RESTART:
|
|
|
|
case LDAP_OPT_THREAD_FN_PTRS:
|
|
|
|
return LDAP_LOCAL_ERROR;
|
|
|
|
|
|
|
|
case LDAP_OPT_API_FEATURE_INFO:
|
|
|
|
case LDAP_OPT_API_INFO:
|
|
|
|
return LDAP_UNWILLING_TO_PERFORM;
|
|
|
|
|
|
|
|
case LDAP_OPT_AREC_EXCLUSIVE:
|
|
|
|
case LDAP_OPT_AUTO_RECONNECT:
|
|
|
|
case LDAP_OPT_CLIENT_CERTIFICATE:
|
|
|
|
case LDAP_OPT_DNSDOMAIN_NAME:
|
|
|
|
case LDAP_OPT_ENCRYPT:
|
|
|
|
case LDAP_OPT_ERROR_STRING:
|
|
|
|
case LDAP_OPT_FAST_CONCURRENT_BIND:
|
|
|
|
case LDAP_OPT_GETDSNAME_FLAGS:
|
|
|
|
case LDAP_OPT_HOST_NAME:
|
|
|
|
case LDAP_OPT_HOST_REACHABLE:
|
|
|
|
case LDAP_OPT_PING_KEEP_ALIVE:
|
|
|
|
case LDAP_OPT_PING_LIMIT:
|
|
|
|
case LDAP_OPT_PING_WAIT_TIME:
|
|
|
|
case LDAP_OPT_PROMPT_CREDENTIALS:
|
|
|
|
case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
|
|
|
|
case LDAP_OPT_REFERRAL_CALLBACK:
|
|
|
|
case LDAP_OPT_REFERRAL_HOP_LIMIT:
|
|
|
|
case LDAP_OPT_ROOTDSE_CACHE:
|
|
|
|
case LDAP_OPT_SASL_METHOD:
|
|
|
|
case LDAP_OPT_SECURITY_CONTEXT:
|
|
|
|
case LDAP_OPT_SEND_TIMEOUT:
|
|
|
|
case LDAP_OPT_SERVER_CERTIFICATE:
|
|
|
|
case LDAP_OPT_SERVER_ERROR:
|
|
|
|
case LDAP_OPT_SERVER_EXT_ERROR:
|
|
|
|
case LDAP_OPT_SIGN:
|
|
|
|
case LDAP_OPT_SSL:
|
|
|
|
case LDAP_OPT_SSL_INFO:
|
|
|
|
case LDAP_OPT_SSPI_FLAGS:
|
|
|
|
case LDAP_OPT_TCP_KEEPALIVE:
|
2005-08-09 22:35:17 +02:00
|
|
|
FIXME( "Unsupported option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NOT_SUPPORTED;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unknown option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_LOCAL_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
static BOOL query_supported_server_ctrls( LDAP *ld )
|
2020-04-03 10:57:03 +02:00
|
|
|
{
|
|
|
|
char *attrs[] = { (char *)"supportedControl", NULL };
|
2021-04-16 09:59:17 +02:00
|
|
|
void *res, *entry;
|
2021-04-20 11:42:20 +02:00
|
|
|
struct bervalU **ctrls = SERVER_CTRLS(ld);
|
2021-04-16 09:59:17 +02:00
|
|
|
ULONG ret;
|
2020-04-03 10:57:03 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if (!ctrls)
|
|
|
|
{
|
|
|
|
struct ldap_search_ext_s_params params = { CTX(ld), (char *)"", LDAP_SCOPE_BASE,
|
|
|
|
(char *)"(objectClass=*)", attrs, FALSE, NULL, NULL, NULL, 0, &res };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_search_ext_s, ¶ms ));
|
|
|
|
}
|
|
|
|
else return TRUE;
|
2020-04-03 10:57:03 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if (ret == LDAP_SUCCESS)
|
2020-04-03 10:57:03 +02:00
|
|
|
{
|
2021-11-04 11:09:04 +01:00
|
|
|
struct ldap_first_entry_params params = { CTX(ld), res, &entry };
|
|
|
|
if (!LDAP_CALL( ldap_first_entry, ¶ms ))
|
|
|
|
{
|
|
|
|
ULONG count, i;
|
|
|
|
struct ldap_get_values_len_params get_params = { CTX(ld), entry, attrs[0], &ctrls };
|
|
|
|
LDAP_CALL( ldap_get_values_len, &get_params );
|
|
|
|
count = LDAP_CALL( ldap_count_values_len, ctrls );
|
|
|
|
for (i = 0; i < count; i++) TRACE("%u: %s\n", i, debugstr_an( ctrls[i]->bv_val, ctrls[i]->bv_len ));
|
|
|
|
*(struct bervalU ***)&SERVER_CTRLS(ld) = ctrls;
|
|
|
|
}
|
2020-04-03 10:57:03 +02:00
|
|
|
}
|
2021-11-04 11:09:04 +01:00
|
|
|
else return FALSE;
|
2020-04-03 10:57:03 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
LDAP_CALL( ldap_msgfree, res );
|
2021-04-20 11:42:20 +02:00
|
|
|
return ctrls != NULL;
|
2020-04-03 10:57:03 +02:00
|
|
|
}
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
static BOOL is_supported_server_ctrls( LDAP *ld, LDAPControlU **ctrls )
|
2020-04-03 10:57:03 +02:00
|
|
|
{
|
|
|
|
ULONG user_count, server_count, i, n, supported = 0;
|
|
|
|
|
|
|
|
if (!query_supported_server_ctrls( ld ))
|
|
|
|
return TRUE; /* can't verify, let the server handle it on next query */
|
|
|
|
|
|
|
|
user_count = controlarraylenU( ctrls );
|
2021-11-04 11:09:04 +01:00
|
|
|
server_count = LDAP_CALL( ldap_count_values_len, SERVER_CTRLS(ld) );
|
2020-04-03 10:57:03 +02:00
|
|
|
|
|
|
|
for (n = 0; n < user_count; n++)
|
|
|
|
{
|
2020-04-06 12:11:39 +02:00
|
|
|
TRACE("looking for %s\n", debugstr_a(ctrls[n]->ldctl_oid));
|
|
|
|
|
2020-04-03 10:57:03 +02:00
|
|
|
for (i = 0; i < server_count; i++)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
struct bervalU **server_ctrls = SERVER_CTRLS(ld);
|
|
|
|
if (!strncmp( ctrls[n]->ldctl_oid, server_ctrls[i]->bv_val, server_ctrls[i]->bv_len))
|
2020-04-06 12:11:39 +02:00
|
|
|
{
|
2020-04-03 10:57:03 +02:00
|
|
|
supported++;
|
2020-04-06 12:11:39 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-04-03 10:57:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return supported == user_count;
|
|
|
|
}
|
|
|
|
|
2006-08-16 12:53:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_set_optionW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Set option values for a given LDAP context.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* option [I] Option to set values for.
|
|
|
|
* value [I] Pointer to option values.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Set value to LDAP_OPT_ON or LDAP_OPT_OFF for on/off options.
|
2021-04-16 09:59:17 +02:00
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_set_optionW( LDAP *ld, int option, void *value )
|
2005-08-09 22:35:17 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
ULONG ret;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld) return LDAP_PARAM_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
switch (option)
|
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_SERVER_CONTROLS:
|
2006-08-16 12:53:21 +02:00
|
|
|
{
|
2021-04-16 09:59:17 +02:00
|
|
|
LDAPControlU **ctrlsU;
|
2006-08-16 12:53:21 +02:00
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!(ctrlsU = controlarrayWtoU( value ))) return LDAP_NO_MEMORY;
|
2006-08-16 12:53:21 +02:00
|
|
|
|
2020-04-03 10:57:03 +02:00
|
|
|
if (!is_supported_server_ctrls( ld, ctrlsU ))
|
2021-04-19 10:04:54 +02:00
|
|
|
ret = LDAP_PARAM_ERROR;
|
2020-04-03 10:57:03 +02:00
|
|
|
else
|
2021-11-04 11:09:04 +01:00
|
|
|
{
|
|
|
|
struct ldap_set_option_params params = { CTX(ld), option, ctrlsU };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_set_option, ¶ms ));
|
|
|
|
}
|
2006-08-16 12:53:21 +02:00
|
|
|
controlarrayfreeU( ctrlsU );
|
|
|
|
return ret;
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_REFERRALS:
|
2021-02-18 17:49:25 +01:00
|
|
|
{
|
2021-11-04 11:09:04 +01:00
|
|
|
struct ldap_set_option_params params = { CTX(ld), option, LDAP_OPT_ON };
|
2021-04-19 10:04:54 +02:00
|
|
|
if (value == LDAP_OPT_OFF)
|
2021-11-04 11:09:04 +01:00
|
|
|
params.value = LDAP_OPT_OFF;
|
2021-02-18 17:49:25 +01:00
|
|
|
else
|
|
|
|
FIXME("upgrading referral value %p to LDAP_OPT_ON (OpenLDAP lacks sufficient granularity)\n", value);
|
2021-11-04 11:09:04 +01:00
|
|
|
return map_error( LDAP_CALL( ldap_set_option, ¶ms ));
|
2021-02-18 17:49:25 +01:00
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
case LDAP_OPT_DEREF:
|
|
|
|
case LDAP_OPT_DESC:
|
|
|
|
case LDAP_OPT_ERROR_NUMBER:
|
|
|
|
case LDAP_OPT_PROTOCOL_VERSION:
|
|
|
|
case LDAP_OPT_SIZELIMIT:
|
|
|
|
case LDAP_OPT_TIMELIMIT:
|
2021-11-04 11:09:04 +01:00
|
|
|
{
|
|
|
|
struct ldap_set_option_params params = { CTX(ld), option, value };
|
|
|
|
return map_error( LDAP_CALL( ldap_set_option, ¶ms ));
|
|
|
|
}
|
2021-04-19 10:04:54 +02:00
|
|
|
|
|
|
|
case LDAP_OPT_CACHE_ENABLE:
|
|
|
|
case LDAP_OPT_CACHE_FN_PTRS:
|
|
|
|
case LDAP_OPT_CACHE_STRATEGY:
|
|
|
|
case LDAP_OPT_IO_FN_PTRS:
|
|
|
|
case LDAP_OPT_REBIND_ARG:
|
|
|
|
case LDAP_OPT_REBIND_FN:
|
|
|
|
case LDAP_OPT_RESTART:
|
|
|
|
case LDAP_OPT_THREAD_FN_PTRS:
|
|
|
|
return LDAP_LOCAL_ERROR;
|
|
|
|
|
|
|
|
case LDAP_OPT_API_FEATURE_INFO:
|
|
|
|
case LDAP_OPT_API_INFO:
|
|
|
|
return LDAP_UNWILLING_TO_PERFORM;
|
|
|
|
|
|
|
|
case LDAP_OPT_AREC_EXCLUSIVE:
|
|
|
|
case LDAP_OPT_AUTO_RECONNECT:
|
|
|
|
case LDAP_OPT_CLIENT_CERTIFICATE:
|
|
|
|
case LDAP_OPT_DNSDOMAIN_NAME:
|
|
|
|
case LDAP_OPT_ENCRYPT:
|
|
|
|
case LDAP_OPT_ERROR_STRING:
|
|
|
|
case LDAP_OPT_FAST_CONCURRENT_BIND:
|
|
|
|
case LDAP_OPT_GETDSNAME_FLAGS:
|
|
|
|
case LDAP_OPT_HOST_NAME:
|
|
|
|
case LDAP_OPT_HOST_REACHABLE:
|
|
|
|
case LDAP_OPT_PING_KEEP_ALIVE:
|
|
|
|
case LDAP_OPT_PING_LIMIT:
|
|
|
|
case LDAP_OPT_PING_WAIT_TIME:
|
|
|
|
case LDAP_OPT_PROMPT_CREDENTIALS:
|
|
|
|
case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
|
|
|
|
case LDAP_OPT_REFERRAL_CALLBACK:
|
|
|
|
case LDAP_OPT_REFERRAL_HOP_LIMIT:
|
|
|
|
case LDAP_OPT_ROOTDSE_CACHE:
|
|
|
|
case LDAP_OPT_SASL_METHOD:
|
|
|
|
case LDAP_OPT_SECURITY_CONTEXT:
|
|
|
|
case LDAP_OPT_SEND_TIMEOUT:
|
|
|
|
case LDAP_OPT_SERVER_CERTIFICATE:
|
|
|
|
case LDAP_OPT_SERVER_ERROR:
|
|
|
|
case LDAP_OPT_SERVER_EXT_ERROR:
|
|
|
|
case LDAP_OPT_SIGN:
|
|
|
|
case LDAP_OPT_SSL:
|
|
|
|
case LDAP_OPT_SSL_INFO:
|
|
|
|
case LDAP_OPT_SSPI_FLAGS:
|
|
|
|
case LDAP_OPT_TCP_KEEPALIVE:
|
2005-08-09 22:35:17 +02:00
|
|
|
FIXME( "Unsupported option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_NOT_SUPPORTED;
|
2005-08-09 22:35:17 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unknown option: 0x%02x\n", option );
|
2021-04-19 10:04:54 +02:00
|
|
|
return LDAP_LOCAL_ERROR;
|
2005-08-09 22:35:17 +02:00
|
|
|
}
|
|
|
|
}
|