2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
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.
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.
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
23 #include "wine/port.h"
24 #include "wine/debug.h"
35 #define LDAP_NOT_SUPPORTED 0x5c
38 #include "winldap_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43 /***********************************************************************
44 * ldap_get_optionA (WLDAP32.@)
46 * See ldap_get_optionW.
48 ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
50 ULONG ret = LDAP_NOT_SUPPORTED;
53 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
55 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
59 case WLDAP32_LDAP_OPT_API_FEATURE_INFO:
61 LDAPAPIFeatureInfoW featureW;
62 LDAPAPIFeatureInfoA *featureA = value;
64 if (!featureA->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
66 featureW.ldapaif_info_version = featureA->ldapaif_info_version;
67 featureW.ldapaif_name = strAtoW( featureA->ldapaif_name );
68 featureW.ldapaif_version = 0;
70 if (!featureW.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
72 ret = ldap_get_optionW( ld, option, &featureW );
74 featureA->ldapaif_version = featureW.ldapaif_version;
75 strfreeW( featureW.ldapaif_name );
78 case WLDAP32_LDAP_OPT_API_INFO:
81 LDAPAPIInfoA *infoA = value;
83 memset( &infoW, 0, sizeof(LDAPAPIInfoW) );
84 infoW.ldapai_info_version = infoA->ldapai_info_version;
86 ret = ldap_get_optionW( ld, option, &infoW );
88 infoA->ldapai_api_version = infoW.ldapai_api_version;
89 infoA->ldapai_protocol_version = infoW.ldapai_protocol_version;
91 if (infoW.ldapai_extensions)
93 infoA->ldapai_extensions = strarrayWtoA( infoW.ldapai_extensions );
94 if (!infoA->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
96 if (infoW.ldapai_vendor_name)
98 infoA->ldapai_vendor_name = strWtoA( infoW.ldapai_vendor_name );
99 if (!infoA->ldapai_vendor_name)
101 ldap_value_freeW( infoW.ldapai_extensions );
102 return WLDAP32_LDAP_NO_MEMORY;
105 infoA->ldapai_vendor_version = infoW.ldapai_vendor_version;
107 ldap_value_freeW( infoW.ldapai_extensions );
108 ldap_memfreeW( infoW.ldapai_vendor_name );
112 case WLDAP32_LDAP_OPT_DEREF:
113 case WLDAP32_LDAP_OPT_DESC:
114 case WLDAP32_LDAP_OPT_ERROR_NUMBER:
115 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION:
116 case WLDAP32_LDAP_OPT_REFERRALS:
117 case WLDAP32_LDAP_OPT_SIZELIMIT:
118 case WLDAP32_LDAP_OPT_TIMELIMIT:
119 return ldap_get_optionW( ld, option, value );
121 case WLDAP32_LDAP_OPT_CACHE_ENABLE:
122 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS:
123 case WLDAP32_LDAP_OPT_CACHE_STRATEGY:
124 case WLDAP32_LDAP_OPT_IO_FN_PTRS:
125 case WLDAP32_LDAP_OPT_REBIND_ARG:
126 case WLDAP32_LDAP_OPT_REBIND_FN:
127 case WLDAP32_LDAP_OPT_RESTART:
128 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS:
129 return LDAP_LOCAL_ERROR;
131 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE:
132 case WLDAP32_LDAP_OPT_AUTO_RECONNECT:
133 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE:
134 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME:
135 case WLDAP32_LDAP_OPT_ENCRYPT:
136 case WLDAP32_LDAP_OPT_ERROR_STRING:
137 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND:
138 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS:
139 case WLDAP32_LDAP_OPT_HOST_NAME:
140 case WLDAP32_LDAP_OPT_HOST_REACHABLE:
141 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE:
142 case WLDAP32_LDAP_OPT_PING_LIMIT:
143 case WLDAP32_LDAP_OPT_PING_WAIT_TIME:
144 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS:
145 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG:
146 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK:
147 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT:
148 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE:
149 case WLDAP32_LDAP_OPT_SASL_METHOD:
150 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT:
151 case WLDAP32_LDAP_OPT_SEND_TIMEOUT:
152 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE:
153 case WLDAP32_LDAP_OPT_SERVER_CONTROLS:
154 case WLDAP32_LDAP_OPT_SERVER_ERROR:
155 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR:
156 case WLDAP32_LDAP_OPT_SIGN:
157 case WLDAP32_LDAP_OPT_SSL:
158 case WLDAP32_LDAP_OPT_SSL_INFO:
159 case WLDAP32_LDAP_OPT_SSPI_FLAGS:
160 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE:
161 FIXME( "Unsupported option: 0x%02x\n", option );
162 return LDAP_NOT_SUPPORTED;
165 FIXME( "Unknown option: 0x%02x\n", option );
166 return LDAP_LOCAL_ERROR;
173 /***********************************************************************
174 * ldap_get_optionW (WLDAP32.@)
176 * Retrieve option values for a given LDAP context.
179 * ld [I] Pointer to an LDAP context.
180 * option [I] Option to get values for.
181 * value [O] Pointer to option values.
184 * Success: LDAP_SUCCESS
185 * Failure: An LDAP error code.
187 ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
189 ULONG ret = LDAP_NOT_SUPPORTED;
192 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
194 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
198 case WLDAP32_LDAP_OPT_API_FEATURE_INFO:
200 LDAPAPIFeatureInfo featureU;
201 LDAPAPIFeatureInfoW *featureW = value;
203 if (!featureW->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
205 featureU.ldapaif_info_version = featureW->ldapaif_info_version;
206 featureU.ldapaif_name = strWtoU( featureW->ldapaif_name );
207 featureU.ldapaif_version = 0;
209 if (!featureU.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
211 ret = ldap_get_option( ld, option, &featureU );
213 featureW->ldapaif_version = featureU.ldapaif_version;
214 strfreeU( featureU.ldapaif_name );
217 case WLDAP32_LDAP_OPT_API_INFO:
220 LDAPAPIInfoW *infoW = value;
222 memset( &infoU, 0, sizeof(LDAPAPIInfo) );
223 infoU.ldapai_info_version = infoW->ldapai_info_version;
225 ret = ldap_get_option( ld, option, &infoU );
227 infoW->ldapai_api_version = infoU.ldapai_api_version;
228 infoW->ldapai_protocol_version = infoU.ldapai_protocol_version;
230 if (infoU.ldapai_extensions)
232 infoW->ldapai_extensions = strarrayUtoW( infoU.ldapai_extensions );
233 if (!infoW->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
235 if (infoU.ldapai_vendor_name)
237 infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name );
238 if (!infoW->ldapai_vendor_name)
240 ldap_memvfree( (void **)infoU.ldapai_extensions );
241 return WLDAP32_LDAP_NO_MEMORY;
244 infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
246 ldap_memvfree( (void **)infoU.ldapai_extensions );
247 ldap_memfree( infoU.ldapai_vendor_name );
251 case WLDAP32_LDAP_OPT_DEREF:
252 case WLDAP32_LDAP_OPT_DESC:
253 case WLDAP32_LDAP_OPT_ERROR_NUMBER:
254 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION:
255 case WLDAP32_LDAP_OPT_REFERRALS:
256 case WLDAP32_LDAP_OPT_SIZELIMIT:
257 case WLDAP32_LDAP_OPT_TIMELIMIT:
258 return ldap_get_option( ld, option, value );
260 case WLDAP32_LDAP_OPT_CACHE_ENABLE:
261 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS:
262 case WLDAP32_LDAP_OPT_CACHE_STRATEGY:
263 case WLDAP32_LDAP_OPT_IO_FN_PTRS:
264 case WLDAP32_LDAP_OPT_REBIND_ARG:
265 case WLDAP32_LDAP_OPT_REBIND_FN:
266 case WLDAP32_LDAP_OPT_RESTART:
267 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS:
268 return LDAP_LOCAL_ERROR;
270 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE:
271 case WLDAP32_LDAP_OPT_AUTO_RECONNECT:
272 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE:
273 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME:
274 case WLDAP32_LDAP_OPT_ENCRYPT:
275 case WLDAP32_LDAP_OPT_ERROR_STRING:
276 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND:
277 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS:
278 case WLDAP32_LDAP_OPT_HOST_NAME:
279 case WLDAP32_LDAP_OPT_HOST_REACHABLE:
280 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE:
281 case WLDAP32_LDAP_OPT_PING_LIMIT:
282 case WLDAP32_LDAP_OPT_PING_WAIT_TIME:
283 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS:
284 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG:
285 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK:
286 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT:
287 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE:
288 case WLDAP32_LDAP_OPT_SASL_METHOD:
289 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT:
290 case WLDAP32_LDAP_OPT_SEND_TIMEOUT:
291 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE:
292 case WLDAP32_LDAP_OPT_SERVER_CONTROLS:
293 case WLDAP32_LDAP_OPT_SERVER_ERROR:
294 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR:
295 case WLDAP32_LDAP_OPT_SIGN:
296 case WLDAP32_LDAP_OPT_SSL:
297 case WLDAP32_LDAP_OPT_SSL_INFO:
298 case WLDAP32_LDAP_OPT_SSPI_FLAGS:
299 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE:
300 FIXME( "Unsupported option: 0x%02x\n", option );
301 return LDAP_NOT_SUPPORTED;
304 FIXME( "Unknown option: 0x%02x\n", option );
305 return LDAP_LOCAL_ERROR;
312 /***********************************************************************
313 * ldap_set_optionA (WLDAP32.@)
315 * See ldap_set_optionW.
317 ULONG CDECL ldap_set_optionA( WLDAP32_LDAP *ld, int option, void *value )
319 ULONG ret = LDAP_NOT_SUPPORTED;
322 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
324 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
328 case WLDAP32_LDAP_OPT_SERVER_CONTROLS:
330 LDAPControlW **ctrlsW;
332 ctrlsW = controlarrayAtoW( (LDAPControlA **)value );
333 if (!ctrlsW) return WLDAP32_LDAP_NO_MEMORY;
335 ret = ldap_set_optionW( ld, option, ctrlsW );
336 controlarrayfreeW( ctrlsW );
339 case WLDAP32_LDAP_OPT_DEREF:
340 case WLDAP32_LDAP_OPT_DESC:
341 case WLDAP32_LDAP_OPT_ERROR_NUMBER:
342 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION:
343 case WLDAP32_LDAP_OPT_REFERRALS:
344 case WLDAP32_LDAP_OPT_SIZELIMIT:
345 case WLDAP32_LDAP_OPT_TIMELIMIT:
346 return ldap_set_optionW( ld, option, value );
348 case WLDAP32_LDAP_OPT_CACHE_ENABLE:
349 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS:
350 case WLDAP32_LDAP_OPT_CACHE_STRATEGY:
351 case WLDAP32_LDAP_OPT_IO_FN_PTRS:
352 case WLDAP32_LDAP_OPT_REBIND_ARG:
353 case WLDAP32_LDAP_OPT_REBIND_FN:
354 case WLDAP32_LDAP_OPT_RESTART:
355 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS:
356 return LDAP_LOCAL_ERROR;
358 case WLDAP32_LDAP_OPT_API_FEATURE_INFO:
359 case WLDAP32_LDAP_OPT_API_INFO:
360 return LDAP_UNWILLING_TO_PERFORM;
362 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE:
363 case WLDAP32_LDAP_OPT_AUTO_RECONNECT:
364 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE:
365 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME:
366 case WLDAP32_LDAP_OPT_ENCRYPT:
367 case WLDAP32_LDAP_OPT_ERROR_STRING:
368 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND:
369 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS:
370 case WLDAP32_LDAP_OPT_HOST_NAME:
371 case WLDAP32_LDAP_OPT_HOST_REACHABLE:
372 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE:
373 case WLDAP32_LDAP_OPT_PING_LIMIT:
374 case WLDAP32_LDAP_OPT_PING_WAIT_TIME:
375 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS:
376 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG:
377 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK:
378 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT:
379 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE:
380 case WLDAP32_LDAP_OPT_SASL_METHOD:
381 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT:
382 case WLDAP32_LDAP_OPT_SEND_TIMEOUT:
383 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE:
384 case WLDAP32_LDAP_OPT_SERVER_ERROR:
385 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR:
386 case WLDAP32_LDAP_OPT_SIGN:
387 case WLDAP32_LDAP_OPT_SSL:
388 case WLDAP32_LDAP_OPT_SSL_INFO:
389 case WLDAP32_LDAP_OPT_SSPI_FLAGS:
390 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE:
391 FIXME( "Unsupported option: 0x%02x\n", option );
392 return LDAP_NOT_SUPPORTED;
395 FIXME( "Unknown option: 0x%02x\n", option );
396 return LDAP_LOCAL_ERROR;
403 /***********************************************************************
404 * ldap_set_optionW (WLDAP32.@)
406 * Set option values for a given LDAP context.
409 * ld [I] Pointer to an LDAP context.
410 * option [I] Option to set values for.
411 * value [I] Pointer to option values.
414 * Success: LDAP_SUCCESS
415 * Failure: An LDAP error code.
418 * Set value to LDAP_OPT_ON or LDAP_OPT_OFF for on/off options.
420 ULONG CDECL ldap_set_optionW( WLDAP32_LDAP *ld, int option, void *value )
422 ULONG ret = LDAP_NOT_SUPPORTED;
425 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
427 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
431 case WLDAP32_LDAP_OPT_SERVER_CONTROLS:
433 LDAPControl **ctrlsU;
435 ctrlsU = controlarrayWtoU( (LDAPControlW **)value );
436 if (!ctrlsU) return WLDAP32_LDAP_NO_MEMORY;
438 ret = ldap_set_option( ld, option, ctrlsU );
439 controlarrayfreeU( ctrlsU );
442 case WLDAP32_LDAP_OPT_DEREF:
443 case WLDAP32_LDAP_OPT_DESC:
444 case WLDAP32_LDAP_OPT_ERROR_NUMBER:
445 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION:
446 case WLDAP32_LDAP_OPT_REFERRALS:
447 case WLDAP32_LDAP_OPT_SIZELIMIT:
448 case WLDAP32_LDAP_OPT_TIMELIMIT:
449 return ldap_set_option( ld, option, value );
451 case WLDAP32_LDAP_OPT_CACHE_ENABLE:
452 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS:
453 case WLDAP32_LDAP_OPT_CACHE_STRATEGY:
454 case WLDAP32_LDAP_OPT_IO_FN_PTRS:
455 case WLDAP32_LDAP_OPT_REBIND_ARG:
456 case WLDAP32_LDAP_OPT_REBIND_FN:
457 case WLDAP32_LDAP_OPT_RESTART:
458 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS:
459 return LDAP_LOCAL_ERROR;
461 case WLDAP32_LDAP_OPT_API_FEATURE_INFO:
462 case WLDAP32_LDAP_OPT_API_INFO:
463 return LDAP_UNWILLING_TO_PERFORM;
465 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE:
466 case WLDAP32_LDAP_OPT_AUTO_RECONNECT:
467 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE:
468 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME:
469 case WLDAP32_LDAP_OPT_ENCRYPT:
470 case WLDAP32_LDAP_OPT_ERROR_STRING:
471 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND:
472 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS:
473 case WLDAP32_LDAP_OPT_HOST_NAME:
474 case WLDAP32_LDAP_OPT_HOST_REACHABLE:
475 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE:
476 case WLDAP32_LDAP_OPT_PING_LIMIT:
477 case WLDAP32_LDAP_OPT_PING_WAIT_TIME:
478 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS:
479 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG:
480 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK:
481 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT:
482 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE:
483 case WLDAP32_LDAP_OPT_SASL_METHOD:
484 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT:
485 case WLDAP32_LDAP_OPT_SEND_TIMEOUT:
486 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE:
487 case WLDAP32_LDAP_OPT_SERVER_ERROR:
488 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR:
489 case WLDAP32_LDAP_OPT_SIGN:
490 case WLDAP32_LDAP_OPT_SSL:
491 case WLDAP32_LDAP_OPT_SSL_INFO:
492 case WLDAP32_LDAP_OPT_SSPI_FLAGS:
493 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE:
494 FIXME( "Unsupported option: 0x%02x\n", option );
495 return LDAP_NOT_SUPPORTED;
498 FIXME( "Unknown option: 0x%02x\n", option );
499 return LDAP_LOCAL_ERROR;