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 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 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
);
114 case LDAP_OPT_ERROR_NUMBER
:
115 case LDAP_OPT_PROTOCOL_VERSION
:
116 case LDAP_OPT_REFERRALS
:
117 case LDAP_OPT_SIZELIMIT
:
118 case LDAP_OPT_TIMELIMIT
:
119 return ldap_get_optionW( ld
, option
, value
);
121 case LDAP_OPT_CACHE_ENABLE
:
122 case LDAP_OPT_CACHE_FN_PTRS
:
123 case LDAP_OPT_CACHE_STRATEGY
:
124 case LDAP_OPT_IO_FN_PTRS
:
125 case LDAP_OPT_REBIND_ARG
:
126 case LDAP_OPT_REBIND_FN
:
127 case LDAP_OPT_RESTART
:
128 case LDAP_OPT_THREAD_FN_PTRS
:
129 return LDAP_LOCAL_ERROR
;
131 case LDAP_OPT_AREC_EXCLUSIVE
:
132 case LDAP_OPT_AUTO_RECONNECT
:
133 case LDAP_OPT_CLIENT_CERTIFICATE
:
134 case LDAP_OPT_DNSDOMAIN_NAME
:
135 case LDAP_OPT_ENCRYPT
:
136 case LDAP_OPT_ERROR_STRING
:
137 case LDAP_OPT_FAST_CONCURRENT_BIND
:
138 case LDAP_OPT_GETDSNAME_FLAGS
:
139 case LDAP_OPT_HOST_NAME
:
140 case LDAP_OPT_HOST_REACHABLE
:
141 case LDAP_OPT_PING_KEEP_ALIVE
:
142 case LDAP_OPT_PING_LIMIT
:
143 case LDAP_OPT_PING_WAIT_TIME
:
144 case LDAP_OPT_PROMPT_CREDENTIALS
:
145 case LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
146 case LDAP_OPT_REFERRAL_CALLBACK
:
147 case LDAP_OPT_REFERRAL_HOP_LIMIT
:
148 case LDAP_OPT_ROOTDSE_CACHE
:
149 case LDAP_OPT_SASL_METHOD
:
150 case LDAP_OPT_SECURITY_CONTEXT
:
151 case LDAP_OPT_SEND_TIMEOUT
:
152 case LDAP_OPT_SERVER_CERTIFICATE
:
153 case LDAP_OPT_SERVER_CONTROLS
:
154 case LDAP_OPT_SERVER_ERROR
:
155 case LDAP_OPT_SERVER_EXT_ERROR
:
158 case LDAP_OPT_SSL_INFO
:
159 case LDAP_OPT_SSPI_FLAGS
:
160 case 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 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 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
);
253 case LDAP_OPT_ERROR_NUMBER
:
254 case LDAP_OPT_PROTOCOL_VERSION
:
255 case LDAP_OPT_REFERRALS
:
256 case LDAP_OPT_SIZELIMIT
:
257 case LDAP_OPT_TIMELIMIT
:
258 return ldap_get_option( ld
, option
, value
);
260 case LDAP_OPT_CACHE_ENABLE
:
261 case LDAP_OPT_CACHE_FN_PTRS
:
262 case LDAP_OPT_CACHE_STRATEGY
:
263 case LDAP_OPT_IO_FN_PTRS
:
264 case LDAP_OPT_REBIND_ARG
:
265 case LDAP_OPT_REBIND_FN
:
266 case LDAP_OPT_RESTART
:
267 case LDAP_OPT_THREAD_FN_PTRS
:
268 return LDAP_LOCAL_ERROR
;
270 case LDAP_OPT_AREC_EXCLUSIVE
:
271 case LDAP_OPT_AUTO_RECONNECT
:
272 case LDAP_OPT_CLIENT_CERTIFICATE
:
273 case LDAP_OPT_DNSDOMAIN_NAME
:
274 case LDAP_OPT_ENCRYPT
:
275 case LDAP_OPT_ERROR_STRING
:
276 case LDAP_OPT_FAST_CONCURRENT_BIND
:
277 case LDAP_OPT_GETDSNAME_FLAGS
:
278 case LDAP_OPT_HOST_NAME
:
279 case LDAP_OPT_HOST_REACHABLE
:
280 case LDAP_OPT_PING_KEEP_ALIVE
:
281 case LDAP_OPT_PING_LIMIT
:
282 case LDAP_OPT_PING_WAIT_TIME
:
283 case LDAP_OPT_PROMPT_CREDENTIALS
:
284 case LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
285 case LDAP_OPT_REFERRAL_CALLBACK
:
286 case LDAP_OPT_REFERRAL_HOP_LIMIT
:
287 case LDAP_OPT_ROOTDSE_CACHE
:
288 case LDAP_OPT_SASL_METHOD
:
289 case LDAP_OPT_SECURITY_CONTEXT
:
290 case LDAP_OPT_SEND_TIMEOUT
:
291 case LDAP_OPT_SERVER_CERTIFICATE
:
292 case LDAP_OPT_SERVER_CONTROLS
:
293 case LDAP_OPT_SERVER_ERROR
:
294 case LDAP_OPT_SERVER_EXT_ERROR
:
297 case LDAP_OPT_SSL_INFO
:
298 case LDAP_OPT_SSPI_FLAGS
:
299 case 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 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
);
341 case LDAP_OPT_ERROR_NUMBER
:
342 case LDAP_OPT_PROTOCOL_VERSION
:
343 case LDAP_OPT_REFERRALS
:
344 case LDAP_OPT_SIZELIMIT
:
345 case LDAP_OPT_TIMELIMIT
:
346 return ldap_set_optionW( ld
, option
, value
);
348 case LDAP_OPT_CACHE_ENABLE
:
349 case LDAP_OPT_CACHE_FN_PTRS
:
350 case LDAP_OPT_CACHE_STRATEGY
:
351 case LDAP_OPT_IO_FN_PTRS
:
352 case LDAP_OPT_REBIND_ARG
:
353 case LDAP_OPT_REBIND_FN
:
354 case LDAP_OPT_RESTART
:
355 case LDAP_OPT_THREAD_FN_PTRS
:
356 return LDAP_LOCAL_ERROR
;
358 case LDAP_OPT_API_FEATURE_INFO
:
359 case LDAP_OPT_API_INFO
:
360 return LDAP_UNWILLING_TO_PERFORM
;
362 case LDAP_OPT_AREC_EXCLUSIVE
:
363 case LDAP_OPT_AUTO_RECONNECT
:
364 case LDAP_OPT_CLIENT_CERTIFICATE
:
365 case LDAP_OPT_DNSDOMAIN_NAME
:
366 case LDAP_OPT_ENCRYPT
:
367 case LDAP_OPT_ERROR_STRING
:
368 case LDAP_OPT_FAST_CONCURRENT_BIND
:
369 case LDAP_OPT_GETDSNAME_FLAGS
:
370 case LDAP_OPT_HOST_NAME
:
371 case LDAP_OPT_HOST_REACHABLE
:
372 case LDAP_OPT_PING_KEEP_ALIVE
:
373 case LDAP_OPT_PING_LIMIT
:
374 case LDAP_OPT_PING_WAIT_TIME
:
375 case LDAP_OPT_PROMPT_CREDENTIALS
:
376 case LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
377 case LDAP_OPT_REFERRAL_CALLBACK
:
378 case LDAP_OPT_REFERRAL_HOP_LIMIT
:
379 case LDAP_OPT_ROOTDSE_CACHE
:
380 case LDAP_OPT_SASL_METHOD
:
381 case LDAP_OPT_SECURITY_CONTEXT
:
382 case LDAP_OPT_SEND_TIMEOUT
:
383 case LDAP_OPT_SERVER_CERTIFICATE
:
384 case LDAP_OPT_SERVER_ERROR
:
385 case LDAP_OPT_SERVER_EXT_ERROR
:
388 case LDAP_OPT_SSL_INFO
:
389 case LDAP_OPT_SSPI_FLAGS
:
390 case 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 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
);
444 case LDAP_OPT_ERROR_NUMBER
:
445 case LDAP_OPT_PROTOCOL_VERSION
:
446 case LDAP_OPT_REFERRALS
:
447 case LDAP_OPT_SIZELIMIT
:
448 case LDAP_OPT_TIMELIMIT
:
449 return ldap_set_option( ld
, option
, value
);
451 case LDAP_OPT_CACHE_ENABLE
:
452 case LDAP_OPT_CACHE_FN_PTRS
:
453 case LDAP_OPT_CACHE_STRATEGY
:
454 case LDAP_OPT_IO_FN_PTRS
:
455 case LDAP_OPT_REBIND_ARG
:
456 case LDAP_OPT_REBIND_FN
:
457 case LDAP_OPT_RESTART
:
458 case LDAP_OPT_THREAD_FN_PTRS
:
459 return LDAP_LOCAL_ERROR
;
461 case LDAP_OPT_API_FEATURE_INFO
:
462 case LDAP_OPT_API_INFO
:
463 return LDAP_UNWILLING_TO_PERFORM
;
465 case LDAP_OPT_AREC_EXCLUSIVE
:
466 case LDAP_OPT_AUTO_RECONNECT
:
467 case LDAP_OPT_CLIENT_CERTIFICATE
:
468 case LDAP_OPT_DNSDOMAIN_NAME
:
469 case LDAP_OPT_ENCRYPT
:
470 case LDAP_OPT_ERROR_STRING
:
471 case LDAP_OPT_FAST_CONCURRENT_BIND
:
472 case LDAP_OPT_GETDSNAME_FLAGS
:
473 case LDAP_OPT_HOST_NAME
:
474 case LDAP_OPT_HOST_REACHABLE
:
475 case LDAP_OPT_PING_KEEP_ALIVE
:
476 case LDAP_OPT_PING_LIMIT
:
477 case LDAP_OPT_PING_WAIT_TIME
:
478 case LDAP_OPT_PROMPT_CREDENTIALS
:
479 case LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
480 case LDAP_OPT_REFERRAL_CALLBACK
:
481 case LDAP_OPT_REFERRAL_HOP_LIMIT
:
482 case LDAP_OPT_ROOTDSE_CACHE
:
483 case LDAP_OPT_SASL_METHOD
:
484 case LDAP_OPT_SECURITY_CONTEXT
:
485 case LDAP_OPT_SEND_TIMEOUT
:
486 case LDAP_OPT_SERVER_CERTIFICATE
:
487 case LDAP_OPT_SERVER_ERROR
:
488 case LDAP_OPT_SERVER_EXT_ERROR
:
491 case LDAP_OPT_SSL_INFO
:
492 case LDAP_OPT_SSPI_FLAGS
:
493 case 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
;