ReactOS 0.4.16-dev-297-gc569aee
option.c
Go to the documentation of this file.
1/*
2 * WLDAP32 - LDAP support for Wine
3 *
4 * Copyright 2005 Hans Leidekker
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "config.h"
22#include "wine/port.h"
23
24#include <stdarg.h>
25#ifdef HAVE_LDAP_H
26#include <ldap.h>
27#endif
28
29#include "windef.h"
30#include "winbase.h"
31#include "winnls.h"
32
33#include "winldap_private.h"
34#include "wldap32.h"
35#include "wine/debug.h"
36
38
39/***********************************************************************
40 * ldap_get_optionA (WLDAP32.@)
41 *
42 * See ldap_get_optionW.
43 */
45{
47#ifdef HAVE_LDAP
48
49 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
50
51 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
52
53 switch (option)
54 {
56 {
57 LDAPAPIFeatureInfoW featureW;
58 LDAPAPIFeatureInfoA *featureA = value;
59
60 if (!featureA->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
61
62 featureW.ldapaif_info_version = featureA->ldapaif_info_version;
63 featureW.ldapaif_name = strAtoW( featureA->ldapaif_name );
64 featureW.ldapaif_version = 0;
65
66 if (!featureW.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
67
68 ret = ldap_get_optionW( ld, option, &featureW );
69
70 featureA->ldapaif_version = featureW.ldapaif_version;
71 strfreeW( featureW.ldapaif_name );
72 return ret;
73 }
75 {
78
79 memset( &infoW, 0, sizeof(LDAPAPIInfoW) );
80 infoW.ldapai_info_version = infoA->ldapai_info_version;
81
83
84 infoA->ldapai_api_version = infoW.ldapai_api_version;
85 infoA->ldapai_protocol_version = infoW.ldapai_protocol_version;
86
87 if (infoW.ldapai_extensions)
88 {
89 infoA->ldapai_extensions = strarrayWtoA( infoW.ldapai_extensions );
90 if (!infoA->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
91 }
92 if (infoW.ldapai_vendor_name)
93 {
94 infoA->ldapai_vendor_name = strWtoA( infoW.ldapai_vendor_name );
95 if (!infoA->ldapai_vendor_name)
96 {
97 ldap_value_freeW( infoW.ldapai_extensions );
99 }
100 }
101 infoA->ldapai_vendor_version = infoW.ldapai_vendor_version;
102
103 ldap_value_freeW( infoW.ldapai_extensions );
104 ldap_memfreeW( infoW.ldapai_vendor_name );
105 return ret;
106 }
107
115 return ldap_get_optionW( ld, option, value );
116
125 return LDAP_LOCAL_ERROR;
126
157 FIXME( "Unsupported option: 0x%02x\n", option );
159
160 default:
161 FIXME( "Unknown option: 0x%02x\n", option );
163 }
164
165#endif
166 return ret;
167}
168
169/***********************************************************************
170 * ldap_get_optionW (WLDAP32.@)
171 *
172 * Retrieve option values for a given LDAP context.
173 *
174 * PARAMS
175 * ld [I] Pointer to an LDAP context.
176 * option [I] Option to get values for.
177 * value [O] Pointer to option values.
178 *
179 * RETURNS
180 * Success: LDAP_SUCCESS
181 * Failure: An LDAP error code.
182 */
184{
186#ifdef HAVE_LDAP
187
188 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
189
190 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
191
192 switch (option)
193 {
195 {
196 LDAPAPIFeatureInfo featureU;
197 LDAPAPIFeatureInfoW *featureW = value;
198
199 if (!featureW->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
200
201 featureU.ldapaif_info_version = featureW->ldapaif_info_version;
202 featureU.ldapaif_name = strWtoU( featureW->ldapaif_name );
203 featureU.ldapaif_version = 0;
204
205 if (!featureU.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
206
207 ret = map_error( ldap_get_option( ld, option, &featureU ));
208
209 featureW->ldapaif_version = featureU.ldapaif_version;
210 strfreeU( featureU.ldapaif_name );
211 return ret;
212 }
214 {
215 LDAPAPIInfo infoU;
217
218 memset( &infoU, 0, sizeof(LDAPAPIInfo) );
219 infoU.ldapai_info_version = infoW->ldapai_info_version;
220
221 ret = map_error( ldap_get_option( ld, option, &infoU ));
222
223 infoW->ldapai_api_version = infoU.ldapai_api_version;
224 infoW->ldapai_protocol_version = infoU.ldapai_protocol_version;
225
226 if (infoU.ldapai_extensions)
227 {
228 infoW->ldapai_extensions = strarrayUtoW( infoU.ldapai_extensions );
229 if (!infoW->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
230 }
231 if (infoU.ldapai_vendor_name)
232 {
233 infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name );
234 if (!infoW->ldapai_vendor_name)
235 {
236 ldap_memvfree( (void **)infoU.ldapai_extensions );
238 }
239 }
240 infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
241
242 ldap_memvfree( (void **)infoU.ldapai_extensions );
243 ldap_memfree( infoU.ldapai_vendor_name );
244 return ret;
245 }
246
254 return map_error( ldap_get_option( ld, option, value ));
255
265
296 FIXME( "Unsupported option: 0x%02x\n", option );
298
299 default:
300 FIXME( "Unknown option: 0x%02x\n", option );
302 }
303
304#endif
305 return ret;
306}
307
308/***********************************************************************
309 * ldap_set_optionA (WLDAP32.@)
310 *
311 * See ldap_set_optionW.
312 */
314{
316#ifdef HAVE_LDAP
317
318 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
319
320 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
321
322 switch (option)
323 {
325 {
326 LDAPControlW **ctrlsW;
327
328 ctrlsW = controlarrayAtoW( value );
329 if (!ctrlsW) return WLDAP32_LDAP_NO_MEMORY;
330
331 ret = ldap_set_optionW( ld, option, ctrlsW );
332 controlarrayfreeW( ctrlsW );
333 return ret;
334 }
342 return ldap_set_optionW( ld, option, value );
343
353
357
387 FIXME( "Unsupported option: 0x%02x\n", option );
389
390 default:
391 FIXME( "Unknown option: 0x%02x\n", option );
393 }
394
395#endif
396 return ret;
397}
398
399/***********************************************************************
400 * ldap_set_optionW (WLDAP32.@)
401 *
402 * Set option values for a given LDAP context.
403 *
404 * PARAMS
405 * ld [I] Pointer to an LDAP context.
406 * option [I] Option to set values for.
407 * value [I] Pointer to option values.
408 *
409 * RETURNS
410 * Success: LDAP_SUCCESS
411 * Failure: An LDAP error code.
412 *
413 * NOTES
414 * Set value to LDAP_OPT_ON or LDAP_OPT_OFF for on/off options.
415 */
417{
419#ifdef HAVE_LDAP
420
421 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
422
423 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
424
425 switch (option)
426 {
428 {
429 LDAPControl **ctrlsU;
430
431 ctrlsU = controlarrayWtoU( value );
432 if (!ctrlsU) return WLDAP32_LDAP_NO_MEMORY;
433
434 ret = map_error( ldap_set_option( ld, option, ctrlsU ));
435 controlarrayfreeU( ctrlsU );
436 return ret;
437 }
445 return map_error( ldap_set_option( ld, option, value ));
446
456
460
490 FIXME( "Unsupported option: 0x%02x\n", option );
492
493 default:
494 FIXME( "Unknown option: 0x%02x\n", option );
496 }
497
498#endif
499 return ret;
500}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define CDECL
Definition: compat.h:29
static UINT map_error(DWORD error)
Definition: service.c:35
void CDECL ldap_memfreeW(PWCHAR block)
Definition: misc.c:421
static LPWSTR strAtoW(const char *str)
static const SecPkgInfoW infoW
Definition: kerberos.c:293
static const SecPkgInfoA infoA
Definition: kerberos.c:302
ULONG CDECL ldap_get_optionW(WLDAP32_LDAP *ld, int option, void *value)
Definition: option.c:183
ULONG CDECL ldap_get_optionA(WLDAP32_LDAP *ld, int option, void *value)
Definition: option.c:44
ULONG CDECL ldap_set_optionW(WLDAP32_LDAP *ld, int option, void *value)
Definition: option.c:416
ULONG CDECL ldap_set_optionA(WLDAP32_LDAP *ld, int option, void *value)
Definition: option.c:313
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: getopt.h:109
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
ULONG CDECL ldap_value_freeW(PWCHAR *vals)
Definition: value.c:364
int ret
#define LDAPControl
Definition: winldap.h:620
#define ldap_memfree
Definition: winldap.h:688
#define LDAPAPIInfo
Definition: winldap.h:626
#define LDAP_LOCAL_ERROR
Definition: winldap.h:102
#define ldap_set_option
Definition: winldap.h:641
#define LDAPAPIFeatureInfo
Definition: winldap.h:628
#define ldap_get_option
Definition: winldap.h:640
#define WLDAP32_LDAP_OPT_IO_FN_PTRS
#define WLDAP32_LDAP_OPT_HOST_REACHABLE
#define WLDAP32_LDAP_OPT_PROTOCOL_VERSION
#define WLDAP32_LDAP_OPT_REBIND_FN
#define WLDAP32_LDAP_OPT_CACHE_FN_PTRS
#define WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
#define WLDAP32_LDAP_OPT_RESTART
#define WLDAP32_LDAP_OPT_THREAD_FN_PTRS
#define WLDAP32_LDAP_OPT_DEREF
@ WLDAP32_LDAP_LOCAL_ERROR
@ WLDAP32_LDAP_UNWILLING_TO_PERFORM
@ WLDAP32_LDAP_PARAM_ERROR
@ WLDAP32_LDAP_NOT_SUPPORTED
@ WLDAP32_LDAP_NO_MEMORY
#define WLDAP32_LDAP_OPT_SASL_METHOD
#define WLDAP32_LDAP_OPT_SSPI_FLAGS
#define WLDAP32_LDAP_OPT_SIZELIMIT
#define WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
#define WLDAP32_LDAP_OPT_SECURITY_CONTEXT
#define WLDAP32_LDAP_OPT_HOST_NAME
#define WLDAP32_LDAP_OPT_ERROR_STRING
#define WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
#define WLDAP32_LDAP_OPT_CACHE_STRATEGY
#define WLDAP32_LDAP_OPT_SEND_TIMEOUT
#define WLDAP32_LDAP_OPT_REFERRALS
#define WLDAP32_LDAP_OPT_PING_LIMIT
#define WLDAP32_LDAP_OPT_TIMELIMIT
#define WLDAP32_LDAP_OPT_API_FEATURE_INFO
#define WLDAP32_LDAP_OPT_SSL_INFO
#define WLDAP32_LDAP_OPT_TCP_KEEPALIVE
#define WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
#define WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
#define WLDAP32_LDAP_OPT_ERROR_NUMBER
#define WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
#define WLDAP32_LDAP_OPT_AUTO_RECONNECT
#define WLDAP32_LDAP_OPT_DESC
#define WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
#define WLDAP32_LDAP_OPT_SERVER_ERROR
#define WLDAP32_LDAP_OPT_SERVER_CONTROLS
#define WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
#define WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
#define WLDAP32_LDAP_OPT_PING_WAIT_TIME
#define WLDAP32_LDAP_OPT_SIGN
#define WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
#define WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
#define WLDAP32_LDAP_OPT_ROOTDSE_CACHE
#define WLDAP32_LDAP_OPT_REBIND_ARG
#define WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
#define WLDAP32_LDAP_OPT_API_INFO
#define WLDAP32_LDAP_OPT_CACHE_ENABLE
#define WLDAP32_LDAP_OPT_ENCRYPT
#define WLDAP32_LDAP_OPT_SSL
static LPSTR strWtoA(LPCWSTR str)
Definition: wldap32.h:62
static void strfreeU(char *str)
Definition: wldap32.h:108
static void strfreeW(LPWSTR str)
Definition: wldap32.h:103
static char * strWtoU(LPCWSTR str)
Definition: wldap32.h:74
static LPWSTR * strarrayUtoW(char **strarray)
Definition: wldap32.h:194
static LPSTR * strarrayWtoA(LPWSTR *strarray)
Definition: wldap32.h:154
static LPWSTR strUtoW(char *str)
Definition: wldap32.h:86