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
22 #include "wine/port.h"
33 #include "winldap_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
39 /***********************************************************************
40 * ldap_get_optionA (WLDAP32.@)
42 * See ldap_get_optionW.
44 ULONG CDECL
ldap_get_optionA( WLDAP32_LDAP
*ld
, int option
, void *value
)
46 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
49 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
51 if (!ld
|| !value
) return WLDAP32_LDAP_PARAM_ERROR
;
55 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
57 LDAPAPIFeatureInfoW featureW
;
58 LDAPAPIFeatureInfoA
*featureA
= value
;
60 if (!featureA
->ldapaif_name
) return WLDAP32_LDAP_PARAM_ERROR
;
62 featureW
.ldapaif_info_version
= featureA
->ldapaif_info_version
;
63 featureW
.ldapaif_name
= strAtoW( featureA
->ldapaif_name
);
64 featureW
.ldapaif_version
= 0;
66 if (!featureW
.ldapaif_name
) return WLDAP32_LDAP_NO_MEMORY
;
68 ret
= ldap_get_optionW( ld
, option
, &featureW
);
70 featureA
->ldapaif_version
= featureW
.ldapaif_version
;
71 strfreeW( featureW
.ldapaif_name
);
74 case WLDAP32_LDAP_OPT_API_INFO
:
77 LDAPAPIInfoA
*infoA
= value
;
79 memset( &infoW
, 0, sizeof(LDAPAPIInfoW
) );
80 infoW
.ldapai_info_version
= infoA
->ldapai_info_version
;
82 ret
= ldap_get_optionW( ld
, option
, &infoW
);
84 infoA
->ldapai_api_version
= infoW
.ldapai_api_version
;
85 infoA
->ldapai_protocol_version
= infoW
.ldapai_protocol_version
;
87 if (infoW
.ldapai_extensions
)
89 infoA
->ldapai_extensions
= strarrayWtoA( infoW
.ldapai_extensions
);
90 if (!infoA
->ldapai_extensions
) return WLDAP32_LDAP_NO_MEMORY
;
92 if (infoW
.ldapai_vendor_name
)
94 infoA
->ldapai_vendor_name
= strWtoA( infoW
.ldapai_vendor_name
);
95 if (!infoA
->ldapai_vendor_name
)
97 ldap_value_freeW( infoW
.ldapai_extensions
);
98 return WLDAP32_LDAP_NO_MEMORY
;
101 infoA
->ldapai_vendor_version
= infoW
.ldapai_vendor_version
;
103 ldap_value_freeW( infoW
.ldapai_extensions
);
104 ldap_memfreeW( infoW
.ldapai_vendor_name
);
108 case WLDAP32_LDAP_OPT_DEREF
:
109 case WLDAP32_LDAP_OPT_DESC
:
110 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
111 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
112 case WLDAP32_LDAP_OPT_REFERRALS
:
113 case WLDAP32_LDAP_OPT_SIZELIMIT
:
114 case WLDAP32_LDAP_OPT_TIMELIMIT
:
115 return ldap_get_optionW( ld
, option
, value
);
117 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
118 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
119 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
120 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
121 case WLDAP32_LDAP_OPT_REBIND_ARG
:
122 case WLDAP32_LDAP_OPT_REBIND_FN
:
123 case WLDAP32_LDAP_OPT_RESTART
:
124 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
125 return LDAP_LOCAL_ERROR
;
127 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
128 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
129 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
130 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
131 case WLDAP32_LDAP_OPT_ENCRYPT
:
132 case WLDAP32_LDAP_OPT_ERROR_STRING
:
133 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
134 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
135 case WLDAP32_LDAP_OPT_HOST_NAME
:
136 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
137 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
138 case WLDAP32_LDAP_OPT_PING_LIMIT
:
139 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
140 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
141 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
142 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
143 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
144 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
145 case WLDAP32_LDAP_OPT_SASL_METHOD
:
146 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
147 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
148 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
149 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
150 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
151 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
152 case WLDAP32_LDAP_OPT_SIGN
:
153 case WLDAP32_LDAP_OPT_SSL
:
154 case WLDAP32_LDAP_OPT_SSL_INFO
:
155 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
156 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
157 FIXME( "Unsupported option: 0x%02x\n", option
);
158 return WLDAP32_LDAP_NOT_SUPPORTED
;
161 FIXME( "Unknown option: 0x%02x\n", option
);
162 return WLDAP32_LDAP_LOCAL_ERROR
;
169 /***********************************************************************
170 * ldap_get_optionW (WLDAP32.@)
172 * Retrieve option values for a given LDAP context.
175 * ld [I] Pointer to an LDAP context.
176 * option [I] Option to get values for.
177 * value [O] Pointer to option values.
180 * Success: LDAP_SUCCESS
181 * Failure: An LDAP error code.
183 ULONG CDECL
ldap_get_optionW( WLDAP32_LDAP
*ld
, int option
, void *value
)
185 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
188 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
190 if (!ld
|| !value
) return WLDAP32_LDAP_PARAM_ERROR
;
194 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
196 LDAPAPIFeatureInfo featureU
;
197 LDAPAPIFeatureInfoW
*featureW
= value
;
199 if (!featureW
->ldapaif_name
) return WLDAP32_LDAP_PARAM_ERROR
;
201 featureU
.ldapaif_info_version
= featureW
->ldapaif_info_version
;
202 featureU
.ldapaif_name
= strWtoU( featureW
->ldapaif_name
);
203 featureU
.ldapaif_version
= 0;
205 if (!featureU
.ldapaif_name
) return WLDAP32_LDAP_NO_MEMORY
;
207 ret
= map_error( ldap_get_option( ld
, option
, &featureU
));
209 featureW
->ldapaif_version
= featureU
.ldapaif_version
;
210 strfreeU( featureU
.ldapaif_name
);
213 case WLDAP32_LDAP_OPT_API_INFO
:
216 LDAPAPIInfoW
*infoW
= value
;
218 memset( &infoU
, 0, sizeof(LDAPAPIInfo
) );
219 infoU
.ldapai_info_version
= infoW
->ldapai_info_version
;
221 ret
= map_error( ldap_get_option( ld
, option
, &infoU
));
223 infoW
->ldapai_api_version
= infoU
.ldapai_api_version
;
224 infoW
->ldapai_protocol_version
= infoU
.ldapai_protocol_version
;
226 if (infoU
.ldapai_extensions
)
228 infoW
->ldapai_extensions
= strarrayUtoW( infoU
.ldapai_extensions
);
229 if (!infoW
->ldapai_extensions
) return WLDAP32_LDAP_NO_MEMORY
;
231 if (infoU
.ldapai_vendor_name
)
233 infoW
->ldapai_vendor_name
= strUtoW( infoU
.ldapai_vendor_name
);
234 if (!infoW
->ldapai_vendor_name
)
236 ldap_memvfree( (void **)infoU
.ldapai_extensions
);
237 return WLDAP32_LDAP_NO_MEMORY
;
240 infoW
->ldapai_vendor_version
= infoU
.ldapai_vendor_version
;
242 ldap_memvfree( (void **)infoU
.ldapai_extensions
);
243 ldap_memfree( infoU
.ldapai_vendor_name
);
247 case WLDAP32_LDAP_OPT_DEREF
:
248 case WLDAP32_LDAP_OPT_DESC
:
249 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
250 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
251 case WLDAP32_LDAP_OPT_REFERRALS
:
252 case WLDAP32_LDAP_OPT_SIZELIMIT
:
253 case WLDAP32_LDAP_OPT_TIMELIMIT
:
254 return map_error( ldap_get_option( ld
, option
, value
));
256 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
257 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
258 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
259 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
260 case WLDAP32_LDAP_OPT_REBIND_ARG
:
261 case WLDAP32_LDAP_OPT_REBIND_FN
:
262 case WLDAP32_LDAP_OPT_RESTART
:
263 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
264 return WLDAP32_LDAP_LOCAL_ERROR
;
266 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
267 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
268 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
269 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
270 case WLDAP32_LDAP_OPT_ENCRYPT
:
271 case WLDAP32_LDAP_OPT_ERROR_STRING
:
272 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
273 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
274 case WLDAP32_LDAP_OPT_HOST_NAME
:
275 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
276 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
277 case WLDAP32_LDAP_OPT_PING_LIMIT
:
278 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
279 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
280 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
281 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
282 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
283 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
284 case WLDAP32_LDAP_OPT_SASL_METHOD
:
285 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
286 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
287 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
288 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
289 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
290 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
291 case WLDAP32_LDAP_OPT_SIGN
:
292 case WLDAP32_LDAP_OPT_SSL
:
293 case WLDAP32_LDAP_OPT_SSL_INFO
:
294 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
295 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
296 FIXME( "Unsupported option: 0x%02x\n", option
);
297 return WLDAP32_LDAP_NOT_SUPPORTED
;
300 FIXME( "Unknown option: 0x%02x\n", option
);
301 return WLDAP32_LDAP_LOCAL_ERROR
;
308 /***********************************************************************
309 * ldap_set_optionA (WLDAP32.@)
311 * See ldap_set_optionW.
313 ULONG CDECL
ldap_set_optionA( WLDAP32_LDAP
*ld
, int option
, void *value
)
315 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
318 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
320 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
324 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
326 LDAPControlW
**ctrlsW
;
328 ctrlsW
= controlarrayAtoW( value
);
329 if (!ctrlsW
) return WLDAP32_LDAP_NO_MEMORY
;
331 ret
= ldap_set_optionW( ld
, option
, ctrlsW
);
332 controlarrayfreeW( ctrlsW
);
335 case WLDAP32_LDAP_OPT_DEREF
:
336 case WLDAP32_LDAP_OPT_DESC
:
337 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
338 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
339 case WLDAP32_LDAP_OPT_REFERRALS
:
340 case WLDAP32_LDAP_OPT_SIZELIMIT
:
341 case WLDAP32_LDAP_OPT_TIMELIMIT
:
342 return ldap_set_optionW( ld
, option
, value
);
344 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
345 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
346 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
347 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
348 case WLDAP32_LDAP_OPT_REBIND_ARG
:
349 case WLDAP32_LDAP_OPT_REBIND_FN
:
350 case WLDAP32_LDAP_OPT_RESTART
:
351 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
352 return WLDAP32_LDAP_LOCAL_ERROR
;
354 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
355 case WLDAP32_LDAP_OPT_API_INFO
:
356 return WLDAP32_LDAP_UNWILLING_TO_PERFORM
;
358 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
359 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
360 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
361 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
362 case WLDAP32_LDAP_OPT_ENCRYPT
:
363 case WLDAP32_LDAP_OPT_ERROR_STRING
:
364 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
365 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
366 case WLDAP32_LDAP_OPT_HOST_NAME
:
367 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
368 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
369 case WLDAP32_LDAP_OPT_PING_LIMIT
:
370 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
371 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
372 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
373 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
374 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
375 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
376 case WLDAP32_LDAP_OPT_SASL_METHOD
:
377 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
378 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
379 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
380 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
381 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
382 case WLDAP32_LDAP_OPT_SIGN
:
383 case WLDAP32_LDAP_OPT_SSL
:
384 case WLDAP32_LDAP_OPT_SSL_INFO
:
385 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
386 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
387 FIXME( "Unsupported option: 0x%02x\n", option
);
388 return WLDAP32_LDAP_NOT_SUPPORTED
;
391 FIXME( "Unknown option: 0x%02x\n", option
);
392 return WLDAP32_LDAP_LOCAL_ERROR
;
399 /***********************************************************************
400 * ldap_set_optionW (WLDAP32.@)
402 * Set option values for a given LDAP context.
405 * ld [I] Pointer to an LDAP context.
406 * option [I] Option to set values for.
407 * value [I] Pointer to option values.
410 * Success: LDAP_SUCCESS
411 * Failure: An LDAP error code.
414 * Set value to LDAP_OPT_ON or LDAP_OPT_OFF for on/off options.
416 ULONG CDECL
ldap_set_optionW( WLDAP32_LDAP
*ld
, int option
, void *value
)
418 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
421 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
423 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
427 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
429 LDAPControl
**ctrlsU
;
431 ctrlsU
= controlarrayWtoU( value
);
432 if (!ctrlsU
) return WLDAP32_LDAP_NO_MEMORY
;
434 ret
= map_error( ldap_set_option( ld
, option
, ctrlsU
));
435 controlarrayfreeU( ctrlsU
);
438 case WLDAP32_LDAP_OPT_DEREF
:
439 case WLDAP32_LDAP_OPT_DESC
:
440 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
441 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
442 case WLDAP32_LDAP_OPT_REFERRALS
:
443 case WLDAP32_LDAP_OPT_SIZELIMIT
:
444 case WLDAP32_LDAP_OPT_TIMELIMIT
:
445 return map_error( ldap_set_option( ld
, option
, value
));
447 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
448 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
449 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
450 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
451 case WLDAP32_LDAP_OPT_REBIND_ARG
:
452 case WLDAP32_LDAP_OPT_REBIND_FN
:
453 case WLDAP32_LDAP_OPT_RESTART
:
454 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
455 return WLDAP32_LDAP_LOCAL_ERROR
;
457 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
458 case WLDAP32_LDAP_OPT_API_INFO
:
459 return WLDAP32_LDAP_UNWILLING_TO_PERFORM
;
461 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
462 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
463 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
464 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
465 case WLDAP32_LDAP_OPT_ENCRYPT
:
466 case WLDAP32_LDAP_OPT_ERROR_STRING
:
467 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
468 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
469 case WLDAP32_LDAP_OPT_HOST_NAME
:
470 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
471 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
472 case WLDAP32_LDAP_OPT_PING_LIMIT
:
473 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
474 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
475 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
476 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
477 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
478 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
479 case WLDAP32_LDAP_OPT_SASL_METHOD
:
480 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
481 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
482 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
483 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
484 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
485 case WLDAP32_LDAP_OPT_SIGN
:
486 case WLDAP32_LDAP_OPT_SSL
:
487 case WLDAP32_LDAP_OPT_SSL_INFO
:
488 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
489 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
490 FIXME( "Unsupported option: 0x%02x\n", option
);
491 return WLDAP32_LDAP_NOT_SUPPORTED
;
494 FIXME( "Unknown option: 0x%02x\n", option
);
495 return WLDAP32_LDAP_LOCAL_ERROR
;