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"
36 #include "winldap_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
41 /***********************************************************************
42 * ldap_get_optionA (WLDAP32.@)
44 * See ldap_get_optionW.
46 ULONG CDECL
ldap_get_optionA( WLDAP32_LDAP
*ld
, int option
, void *value
)
48 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
51 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
53 if (!ld
|| !value
) return WLDAP32_LDAP_PARAM_ERROR
;
57 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
59 LDAPAPIFeatureInfoW featureW
;
60 LDAPAPIFeatureInfoA
*featureA
= value
;
62 if (!featureA
->ldapaif_name
) return WLDAP32_LDAP_PARAM_ERROR
;
64 featureW
.ldapaif_info_version
= featureA
->ldapaif_info_version
;
65 featureW
.ldapaif_name
= strAtoW( featureA
->ldapaif_name
);
66 featureW
.ldapaif_version
= 0;
68 if (!featureW
.ldapaif_name
) return WLDAP32_LDAP_NO_MEMORY
;
70 ret
= ldap_get_optionW( ld
, option
, &featureW
);
72 featureA
->ldapaif_version
= featureW
.ldapaif_version
;
73 strfreeW( featureW
.ldapaif_name
);
76 case WLDAP32_LDAP_OPT_API_INFO
:
79 LDAPAPIInfoA
*infoA
= value
;
81 memset( &infoW
, 0, sizeof(LDAPAPIInfoW
) );
82 infoW
.ldapai_info_version
= infoA
->ldapai_info_version
;
84 ret
= ldap_get_optionW( ld
, option
, &infoW
);
86 infoA
->ldapai_api_version
= infoW
.ldapai_api_version
;
87 infoA
->ldapai_protocol_version
= infoW
.ldapai_protocol_version
;
89 if (infoW
.ldapai_extensions
)
91 infoA
->ldapai_extensions
= strarrayWtoA( infoW
.ldapai_extensions
);
92 if (!infoA
->ldapai_extensions
) return WLDAP32_LDAP_NO_MEMORY
;
94 if (infoW
.ldapai_vendor_name
)
96 infoA
->ldapai_vendor_name
= strWtoA( infoW
.ldapai_vendor_name
);
97 if (!infoA
->ldapai_vendor_name
)
99 ldap_value_freeW( infoW
.ldapai_extensions
);
100 return WLDAP32_LDAP_NO_MEMORY
;
103 infoA
->ldapai_vendor_version
= infoW
.ldapai_vendor_version
;
105 ldap_value_freeW( infoW
.ldapai_extensions
);
106 ldap_memfreeW( infoW
.ldapai_vendor_name
);
110 case WLDAP32_LDAP_OPT_DEREF
:
111 case WLDAP32_LDAP_OPT_DESC
:
112 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
113 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
114 case WLDAP32_LDAP_OPT_REFERRALS
:
115 case WLDAP32_LDAP_OPT_SIZELIMIT
:
116 case WLDAP32_LDAP_OPT_TIMELIMIT
:
117 return ldap_get_optionW( ld
, option
, value
);
119 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
120 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
121 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
122 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
123 case WLDAP32_LDAP_OPT_REBIND_ARG
:
124 case WLDAP32_LDAP_OPT_REBIND_FN
:
125 case WLDAP32_LDAP_OPT_RESTART
:
126 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
127 return LDAP_LOCAL_ERROR
;
129 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
130 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
131 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
132 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
133 case WLDAP32_LDAP_OPT_ENCRYPT
:
134 case WLDAP32_LDAP_OPT_ERROR_STRING
:
135 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
136 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
137 case WLDAP32_LDAP_OPT_HOST_NAME
:
138 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
139 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
140 case WLDAP32_LDAP_OPT_PING_LIMIT
:
141 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
142 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
143 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
144 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
145 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
146 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
147 case WLDAP32_LDAP_OPT_SASL_METHOD
:
148 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
149 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
150 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
151 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
152 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
153 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
154 case WLDAP32_LDAP_OPT_SIGN
:
155 case WLDAP32_LDAP_OPT_SSL
:
156 case WLDAP32_LDAP_OPT_SSL_INFO
:
157 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
158 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
159 FIXME( "Unsupported option: 0x%02x\n", option
);
160 return WLDAP32_LDAP_NOT_SUPPORTED
;
163 FIXME( "Unknown option: 0x%02x\n", option
);
164 return WLDAP32_LDAP_LOCAL_ERROR
;
171 /***********************************************************************
172 * ldap_get_optionW (WLDAP32.@)
174 * Retrieve option values for a given LDAP context.
177 * ld [I] Pointer to an LDAP context.
178 * option [I] Option to get values for.
179 * value [O] Pointer to option values.
182 * Success: LDAP_SUCCESS
183 * Failure: An LDAP error code.
185 ULONG CDECL
ldap_get_optionW( WLDAP32_LDAP
*ld
, int option
, void *value
)
187 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
190 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
192 if (!ld
|| !value
) return WLDAP32_LDAP_PARAM_ERROR
;
196 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
198 LDAPAPIFeatureInfo featureU
;
199 LDAPAPIFeatureInfoW
*featureW
= value
;
201 if (!featureW
->ldapaif_name
) return WLDAP32_LDAP_PARAM_ERROR
;
203 featureU
.ldapaif_info_version
= featureW
->ldapaif_info_version
;
204 featureU
.ldapaif_name
= strWtoU( featureW
->ldapaif_name
);
205 featureU
.ldapaif_version
= 0;
207 if (!featureU
.ldapaif_name
) return WLDAP32_LDAP_NO_MEMORY
;
209 ret
= map_error( ldap_get_option( ld
, option
, &featureU
));
211 featureW
->ldapaif_version
= featureU
.ldapaif_version
;
212 strfreeU( featureU
.ldapaif_name
);
215 case WLDAP32_LDAP_OPT_API_INFO
:
218 LDAPAPIInfoW
*infoW
= value
;
220 memset( &infoU
, 0, sizeof(LDAPAPIInfo
) );
221 infoU
.ldapai_info_version
= infoW
->ldapai_info_version
;
223 ret
= map_error( ldap_get_option( ld
, option
, &infoU
));
225 infoW
->ldapai_api_version
= infoU
.ldapai_api_version
;
226 infoW
->ldapai_protocol_version
= infoU
.ldapai_protocol_version
;
228 if (infoU
.ldapai_extensions
)
230 infoW
->ldapai_extensions
= strarrayUtoW( infoU
.ldapai_extensions
);
231 if (!infoW
->ldapai_extensions
) return WLDAP32_LDAP_NO_MEMORY
;
233 if (infoU
.ldapai_vendor_name
)
235 infoW
->ldapai_vendor_name
= strUtoW( infoU
.ldapai_vendor_name
);
236 if (!infoW
->ldapai_vendor_name
)
238 ldap_memvfree( (void **)infoU
.ldapai_extensions
);
239 return WLDAP32_LDAP_NO_MEMORY
;
242 infoW
->ldapai_vendor_version
= infoU
.ldapai_vendor_version
;
244 ldap_memvfree( (void **)infoU
.ldapai_extensions
);
245 ldap_memfree( infoU
.ldapai_vendor_name
);
249 case WLDAP32_LDAP_OPT_DEREF
:
250 case WLDAP32_LDAP_OPT_DESC
:
251 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
252 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
253 case WLDAP32_LDAP_OPT_REFERRALS
:
254 case WLDAP32_LDAP_OPT_SIZELIMIT
:
255 case WLDAP32_LDAP_OPT_TIMELIMIT
:
256 return map_error( ldap_get_option( ld
, option
, value
));
258 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
259 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
260 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
261 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
262 case WLDAP32_LDAP_OPT_REBIND_ARG
:
263 case WLDAP32_LDAP_OPT_REBIND_FN
:
264 case WLDAP32_LDAP_OPT_RESTART
:
265 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
266 return WLDAP32_LDAP_LOCAL_ERROR
;
268 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
269 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
270 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
271 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
272 case WLDAP32_LDAP_OPT_ENCRYPT
:
273 case WLDAP32_LDAP_OPT_ERROR_STRING
:
274 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
275 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
276 case WLDAP32_LDAP_OPT_HOST_NAME
:
277 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
278 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
279 case WLDAP32_LDAP_OPT_PING_LIMIT
:
280 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
281 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
282 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
283 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
284 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
285 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
286 case WLDAP32_LDAP_OPT_SASL_METHOD
:
287 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
288 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
289 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
290 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
291 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
292 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
293 case WLDAP32_LDAP_OPT_SIGN
:
294 case WLDAP32_LDAP_OPT_SSL
:
295 case WLDAP32_LDAP_OPT_SSL_INFO
:
296 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
297 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
298 FIXME( "Unsupported option: 0x%02x\n", option
);
299 return WLDAP32_LDAP_NOT_SUPPORTED
;
302 FIXME( "Unknown option: 0x%02x\n", option
);
303 return WLDAP32_LDAP_LOCAL_ERROR
;
310 /***********************************************************************
311 * ldap_set_optionA (WLDAP32.@)
313 * See ldap_set_optionW.
315 ULONG CDECL
ldap_set_optionA( WLDAP32_LDAP
*ld
, int option
, void *value
)
317 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
320 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
322 if (!ld
|| !value
) return WLDAP32_LDAP_PARAM_ERROR
;
326 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
328 LDAPControlW
**ctrlsW
;
330 ctrlsW
= controlarrayAtoW( value
);
331 if (!ctrlsW
) return WLDAP32_LDAP_NO_MEMORY
;
333 ret
= ldap_set_optionW( ld
, option
, ctrlsW
);
334 controlarrayfreeW( ctrlsW
);
337 case WLDAP32_LDAP_OPT_DEREF
:
338 case WLDAP32_LDAP_OPT_DESC
:
339 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
340 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
341 case WLDAP32_LDAP_OPT_REFERRALS
:
342 case WLDAP32_LDAP_OPT_SIZELIMIT
:
343 case WLDAP32_LDAP_OPT_TIMELIMIT
:
344 return ldap_set_optionW( ld
, option
, value
);
346 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
347 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
348 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
349 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
350 case WLDAP32_LDAP_OPT_REBIND_ARG
:
351 case WLDAP32_LDAP_OPT_REBIND_FN
:
352 case WLDAP32_LDAP_OPT_RESTART
:
353 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
354 return WLDAP32_LDAP_LOCAL_ERROR
;
356 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
357 case WLDAP32_LDAP_OPT_API_INFO
:
358 return WLDAP32_LDAP_UNWILLING_TO_PERFORM
;
360 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
361 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
362 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
363 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
364 case WLDAP32_LDAP_OPT_ENCRYPT
:
365 case WLDAP32_LDAP_OPT_ERROR_STRING
:
366 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
367 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
368 case WLDAP32_LDAP_OPT_HOST_NAME
:
369 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
370 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
371 case WLDAP32_LDAP_OPT_PING_LIMIT
:
372 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
373 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
374 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
375 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
376 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
377 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
378 case WLDAP32_LDAP_OPT_SASL_METHOD
:
379 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
380 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
381 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
382 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
383 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
384 case WLDAP32_LDAP_OPT_SIGN
:
385 case WLDAP32_LDAP_OPT_SSL
:
386 case WLDAP32_LDAP_OPT_SSL_INFO
:
387 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
388 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
389 FIXME( "Unsupported option: 0x%02x\n", option
);
390 return WLDAP32_LDAP_NOT_SUPPORTED
;
393 FIXME( "Unknown option: 0x%02x\n", option
);
394 return WLDAP32_LDAP_LOCAL_ERROR
;
401 /***********************************************************************
402 * ldap_set_optionW (WLDAP32.@)
404 * Set option values for a given LDAP context.
407 * ld [I] Pointer to an LDAP context.
408 * option [I] Option to set values for.
409 * value [I] Pointer to option values.
412 * Success: LDAP_SUCCESS
413 * Failure: An LDAP error code.
416 * Set value to LDAP_OPT_ON or LDAP_OPT_OFF for on/off options.
418 ULONG CDECL
ldap_set_optionW( WLDAP32_LDAP
*ld
, int option
, void *value
)
420 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
423 TRACE( "(%p, 0x%08x, %p)\n", ld
, option
, value
);
425 if (!ld
|| !value
) return WLDAP32_LDAP_PARAM_ERROR
;
429 case WLDAP32_LDAP_OPT_SERVER_CONTROLS
:
431 LDAPControl
**ctrlsU
;
433 ctrlsU
= controlarrayWtoU( value
);
434 if (!ctrlsU
) return WLDAP32_LDAP_NO_MEMORY
;
436 ret
= map_error( ldap_set_option( ld
, option
, ctrlsU
));
437 controlarrayfreeU( ctrlsU
);
440 case WLDAP32_LDAP_OPT_DEREF
:
441 case WLDAP32_LDAP_OPT_DESC
:
442 case WLDAP32_LDAP_OPT_ERROR_NUMBER
:
443 case WLDAP32_LDAP_OPT_PROTOCOL_VERSION
:
444 case WLDAP32_LDAP_OPT_REFERRALS
:
445 case WLDAP32_LDAP_OPT_SIZELIMIT
:
446 case WLDAP32_LDAP_OPT_TIMELIMIT
:
447 return map_error( ldap_set_option( ld
, option
, value
));
449 case WLDAP32_LDAP_OPT_CACHE_ENABLE
:
450 case WLDAP32_LDAP_OPT_CACHE_FN_PTRS
:
451 case WLDAP32_LDAP_OPT_CACHE_STRATEGY
:
452 case WLDAP32_LDAP_OPT_IO_FN_PTRS
:
453 case WLDAP32_LDAP_OPT_REBIND_ARG
:
454 case WLDAP32_LDAP_OPT_REBIND_FN
:
455 case WLDAP32_LDAP_OPT_RESTART
:
456 case WLDAP32_LDAP_OPT_THREAD_FN_PTRS
:
457 return WLDAP32_LDAP_LOCAL_ERROR
;
459 case WLDAP32_LDAP_OPT_API_FEATURE_INFO
:
460 case WLDAP32_LDAP_OPT_API_INFO
:
461 return WLDAP32_LDAP_UNWILLING_TO_PERFORM
;
463 case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE
:
464 case WLDAP32_LDAP_OPT_AUTO_RECONNECT
:
465 case WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE
:
466 case WLDAP32_LDAP_OPT_DNSDOMAIN_NAME
:
467 case WLDAP32_LDAP_OPT_ENCRYPT
:
468 case WLDAP32_LDAP_OPT_ERROR_STRING
:
469 case WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND
:
470 case WLDAP32_LDAP_OPT_GETDSNAME_FLAGS
:
471 case WLDAP32_LDAP_OPT_HOST_NAME
:
472 case WLDAP32_LDAP_OPT_HOST_REACHABLE
:
473 case WLDAP32_LDAP_OPT_PING_KEEP_ALIVE
:
474 case WLDAP32_LDAP_OPT_PING_LIMIT
:
475 case WLDAP32_LDAP_OPT_PING_WAIT_TIME
:
476 case WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS
:
477 case WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG
:
478 case WLDAP32_LDAP_OPT_REFERRAL_CALLBACK
:
479 case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT
:
480 case WLDAP32_LDAP_OPT_ROOTDSE_CACHE
:
481 case WLDAP32_LDAP_OPT_SASL_METHOD
:
482 case WLDAP32_LDAP_OPT_SECURITY_CONTEXT
:
483 case WLDAP32_LDAP_OPT_SEND_TIMEOUT
:
484 case WLDAP32_LDAP_OPT_SERVER_CERTIFICATE
:
485 case WLDAP32_LDAP_OPT_SERVER_ERROR
:
486 case WLDAP32_LDAP_OPT_SERVER_EXT_ERROR
:
487 case WLDAP32_LDAP_OPT_SIGN
:
488 case WLDAP32_LDAP_OPT_SSL
:
489 case WLDAP32_LDAP_OPT_SSL_INFO
:
490 case WLDAP32_LDAP_OPT_SSPI_FLAGS
:
491 case WLDAP32_LDAP_OPT_TCP_KEEPALIVE
:
492 FIXME( "Unsupported option: 0x%02x\n", option
);
493 return WLDAP32_LDAP_NOT_SUPPORTED
;
496 FIXME( "Unknown option: 0x%02x\n", option
);
497 return WLDAP32_LDAP_LOCAL_ERROR
;