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 ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
45 ULONG ret = LDAP_NOT_SUPPORTED;
48 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
50 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
54 case LDAP_OPT_API_FEATURE_INFO:
56 LDAPAPIFeatureInfoW featureW;
57 LDAPAPIFeatureInfoA *featureA = value;
59 if (!featureA->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
61 featureW.ldapaif_info_version = featureA->ldapaif_info_version;
62 featureW.ldapaif_name = strAtoW( featureA->ldapaif_name );
63 featureW.ldapaif_version = 0;
65 if (!featureW.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
67 ret = ldap_get_optionW( ld, option, &featureW );
69 featureA->ldapaif_version = featureW.ldapaif_version;
70 strfreeW( featureW.ldapaif_name );
73 case LDAP_OPT_API_INFO:
76 LDAPAPIInfoA *infoA = value;
78 memset( &infoW, 0, sizeof(LDAPAPIInfoW) );
79 infoW.ldapai_info_version = infoA->ldapai_info_version;
81 ret = ldap_get_optionW( ld, option, &infoW );
83 infoA->ldapai_api_version = infoW.ldapai_api_version;
84 infoA->ldapai_protocol_version = infoW.ldapai_protocol_version;
86 if (infoW.ldapai_extensions)
88 infoA->ldapai_extensions = strarrayWtoA( infoW.ldapai_extensions );
89 if (!infoA->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
91 if (infoW.ldapai_vendor_name)
93 infoA->ldapai_vendor_name = strWtoA( infoW.ldapai_vendor_name );
94 if (!infoA->ldapai_vendor_name)
96 ldap_value_freeW( infoW.ldapai_extensions );
97 return WLDAP32_LDAP_NO_MEMORY;
100 infoA->ldapai_vendor_version = infoW.ldapai_vendor_version;
102 ldap_value_freeW( infoW.ldapai_extensions );
103 ldap_memfreeW( infoW.ldapai_vendor_name );
109 case LDAP_OPT_ERROR_NUMBER:
110 case LDAP_OPT_PROTOCOL_VERSION:
111 case LDAP_OPT_REFERRALS:
112 case LDAP_OPT_SIZELIMIT:
113 case LDAP_OPT_TIMELIMIT:
114 return ldap_get_optionW( ld, option, value );
116 case LDAP_OPT_CACHE_ENABLE:
117 case LDAP_OPT_CACHE_FN_PTRS:
118 case LDAP_OPT_CACHE_STRATEGY:
119 case LDAP_OPT_IO_FN_PTRS:
120 case LDAP_OPT_REBIND_ARG:
121 case LDAP_OPT_REBIND_FN:
122 case LDAP_OPT_RESTART:
123 case LDAP_OPT_THREAD_FN_PTRS:
124 return LDAP_LOCAL_ERROR;
126 case LDAP_OPT_AREC_EXCLUSIVE:
127 case LDAP_OPT_AUTO_RECONNECT:
128 case LDAP_OPT_CLIENT_CERTIFICATE:
129 case LDAP_OPT_DNSDOMAIN_NAME:
130 case LDAP_OPT_ENCRYPT:
131 case LDAP_OPT_ERROR_STRING:
132 case LDAP_OPT_FAST_CONCURRENT_BIND:
133 case LDAP_OPT_GETDSNAME_FLAGS:
134 case LDAP_OPT_HOST_NAME:
135 case LDAP_OPT_HOST_REACHABLE:
136 case LDAP_OPT_PING_KEEP_ALIVE:
137 case LDAP_OPT_PING_LIMIT:
138 case LDAP_OPT_PING_WAIT_TIME:
139 case LDAP_OPT_PROMPT_CREDENTIALS:
140 case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
141 case LDAP_OPT_REFERRAL_CALLBACK:
142 case LDAP_OPT_REFERRAL_HOP_LIMIT:
143 case LDAP_OPT_ROOTDSE_CACHE:
144 case LDAP_OPT_SASL_METHOD:
145 case LDAP_OPT_SECURITY_CONTEXT:
146 case LDAP_OPT_SEND_TIMEOUT:
147 case LDAP_OPT_SERVER_CERTIFICATE:
148 case LDAP_OPT_SERVER_ERROR:
149 case LDAP_OPT_SERVER_EXT_ERROR:
152 case LDAP_OPT_SSL_INFO:
153 case LDAP_OPT_SSPI_FLAGS:
154 case LDAP_OPT_TCP_KEEPALIVE:
155 FIXME( "Unsupported option: 0x%02x\n", option );
156 return LDAP_NOT_SUPPORTED;
159 FIXME( "Unknown option: 0x%02x\n", option );
160 return LDAP_LOCAL_ERROR;
167 ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
169 ULONG ret = LDAP_NOT_SUPPORTED;
172 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
174 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
178 case LDAP_OPT_API_FEATURE_INFO:
180 LDAPAPIFeatureInfo featureU;
181 LDAPAPIFeatureInfoW *featureW = value;
183 if (!featureW->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
185 featureU.ldapaif_info_version = featureW->ldapaif_info_version;
186 featureU.ldapaif_name = strWtoU( featureW->ldapaif_name );
187 featureU.ldapaif_version = 0;
189 if (!featureU.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
191 ret = ldap_get_option( ld, option, &featureU );
193 featureW->ldapaif_version = featureU.ldapaif_version;
194 strfreeU( featureU.ldapaif_name );
197 case LDAP_OPT_API_INFO:
200 LDAPAPIInfoW *infoW = value;
202 memset( &infoU, 0, sizeof(LDAPAPIInfo) );
203 infoU.ldapai_info_version = infoW->ldapai_info_version;
205 ret = ldap_get_option( ld, option, &infoU );
207 infoW->ldapai_api_version = infoU.ldapai_api_version;
208 infoW->ldapai_protocol_version = infoU.ldapai_protocol_version;
210 if (infoU.ldapai_extensions)
212 infoW->ldapai_extensions = strarrayUtoW( infoU.ldapai_extensions );
213 if (!infoW->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
215 if (infoU.ldapai_vendor_name)
217 infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name );
218 if (!infoW->ldapai_vendor_name)
220 ldap_memvfree( (void **)infoU.ldapai_extensions );
221 return WLDAP32_LDAP_NO_MEMORY;
224 infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
226 ldap_memvfree( (void **)infoU.ldapai_extensions );
227 ldap_memfree( infoU.ldapai_vendor_name );
233 case LDAP_OPT_ERROR_NUMBER:
234 case LDAP_OPT_PROTOCOL_VERSION:
235 case LDAP_OPT_REFERRALS:
236 case LDAP_OPT_SIZELIMIT:
237 case LDAP_OPT_TIMELIMIT:
238 return ldap_get_option( ld, option, value );
240 case LDAP_OPT_CACHE_ENABLE:
241 case LDAP_OPT_CACHE_FN_PTRS:
242 case LDAP_OPT_CACHE_STRATEGY:
243 case LDAP_OPT_IO_FN_PTRS:
244 case LDAP_OPT_REBIND_ARG:
245 case LDAP_OPT_REBIND_FN:
246 case LDAP_OPT_RESTART:
247 case LDAP_OPT_THREAD_FN_PTRS:
248 return LDAP_LOCAL_ERROR;
250 case LDAP_OPT_AREC_EXCLUSIVE:
251 case LDAP_OPT_AUTO_RECONNECT:
252 case LDAP_OPT_CLIENT_CERTIFICATE:
253 case LDAP_OPT_DNSDOMAIN_NAME:
254 case LDAP_OPT_ENCRYPT:
255 case LDAP_OPT_ERROR_STRING:
256 case LDAP_OPT_FAST_CONCURRENT_BIND:
257 case LDAP_OPT_GETDSNAME_FLAGS:
258 case LDAP_OPT_HOST_NAME:
259 case LDAP_OPT_HOST_REACHABLE:
260 case LDAP_OPT_PING_KEEP_ALIVE:
261 case LDAP_OPT_PING_LIMIT:
262 case LDAP_OPT_PING_WAIT_TIME:
263 case LDAP_OPT_PROMPT_CREDENTIALS:
264 case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
265 case LDAP_OPT_REFERRAL_CALLBACK:
266 case LDAP_OPT_REFERRAL_HOP_LIMIT:
267 case LDAP_OPT_ROOTDSE_CACHE:
268 case LDAP_OPT_SASL_METHOD:
269 case LDAP_OPT_SECURITY_CONTEXT:
270 case LDAP_OPT_SEND_TIMEOUT:
271 case LDAP_OPT_SERVER_CERTIFICATE:
272 case LDAP_OPT_SERVER_ERROR:
273 case LDAP_OPT_SERVER_EXT_ERROR:
276 case LDAP_OPT_SSL_INFO:
277 case LDAP_OPT_SSPI_FLAGS:
278 case LDAP_OPT_TCP_KEEPALIVE:
279 FIXME( "Unsupported option: 0x%02x\n", option );
280 return LDAP_NOT_SUPPORTED;
283 FIXME( "Unknown option: 0x%02x\n", option );
284 return LDAP_LOCAL_ERROR;
291 ULONG CDECL ldap_set_optionA( WLDAP32_LDAP *ld, int option, void *value )
293 ULONG ret = LDAP_NOT_SUPPORTED;
296 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
298 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
304 case LDAP_OPT_ERROR_NUMBER:
305 case LDAP_OPT_PROTOCOL_VERSION:
306 case LDAP_OPT_REFERRALS:
307 case LDAP_OPT_SIZELIMIT:
308 case LDAP_OPT_TIMELIMIT:
309 return ldap_set_optionW( ld, option, value );
311 case LDAP_OPT_CACHE_ENABLE:
312 case LDAP_OPT_CACHE_FN_PTRS:
313 case LDAP_OPT_CACHE_STRATEGY:
314 case LDAP_OPT_IO_FN_PTRS:
315 case LDAP_OPT_REBIND_ARG:
316 case LDAP_OPT_REBIND_FN:
317 case LDAP_OPT_RESTART:
318 case LDAP_OPT_THREAD_FN_PTRS:
319 return LDAP_LOCAL_ERROR;
321 case LDAP_OPT_API_FEATURE_INFO:
322 case LDAP_OPT_API_INFO:
323 return LDAP_UNWILLING_TO_PERFORM;
325 case LDAP_OPT_AREC_EXCLUSIVE:
326 case LDAP_OPT_AUTO_RECONNECT:
327 case LDAP_OPT_CLIENT_CERTIFICATE:
328 case LDAP_OPT_DNSDOMAIN_NAME:
329 case LDAP_OPT_ENCRYPT:
330 case LDAP_OPT_ERROR_STRING:
331 case LDAP_OPT_FAST_CONCURRENT_BIND:
332 case LDAP_OPT_GETDSNAME_FLAGS:
333 case LDAP_OPT_HOST_NAME:
334 case LDAP_OPT_HOST_REACHABLE:
335 case LDAP_OPT_PING_KEEP_ALIVE:
336 case LDAP_OPT_PING_LIMIT:
337 case LDAP_OPT_PING_WAIT_TIME:
338 case LDAP_OPT_PROMPT_CREDENTIALS:
339 case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
340 case LDAP_OPT_REFERRAL_CALLBACK:
341 case LDAP_OPT_REFERRAL_HOP_LIMIT:
342 case LDAP_OPT_ROOTDSE_CACHE:
343 case LDAP_OPT_SASL_METHOD:
344 case LDAP_OPT_SECURITY_CONTEXT:
345 case LDAP_OPT_SEND_TIMEOUT:
346 case LDAP_OPT_SERVER_CERTIFICATE:
347 case LDAP_OPT_SERVER_ERROR:
348 case LDAP_OPT_SERVER_EXT_ERROR:
351 case LDAP_OPT_SSL_INFO:
352 case LDAP_OPT_SSPI_FLAGS:
353 case LDAP_OPT_TCP_KEEPALIVE:
354 FIXME( "Unsupported option: 0x%02x\n", option );
355 return LDAP_NOT_SUPPORTED;
358 FIXME( "Unknown option: 0x%02x\n", option );
359 return LDAP_LOCAL_ERROR;
366 ULONG CDECL ldap_set_optionW( WLDAP32_LDAP *ld, int option, void *value )
368 ULONG ret = LDAP_NOT_SUPPORTED;
371 TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
373 if (!ld || !value) return WLDAP32_LDAP_PARAM_ERROR;
379 case LDAP_OPT_ERROR_NUMBER:
380 case LDAP_OPT_PROTOCOL_VERSION:
381 case LDAP_OPT_REFERRALS:
382 case LDAP_OPT_SIZELIMIT:
383 case LDAP_OPT_TIMELIMIT:
384 return ldap_set_option( ld, option, value );
386 case LDAP_OPT_CACHE_ENABLE:
387 case LDAP_OPT_CACHE_FN_PTRS:
388 case LDAP_OPT_CACHE_STRATEGY:
389 case LDAP_OPT_IO_FN_PTRS:
390 case LDAP_OPT_REBIND_ARG:
391 case LDAP_OPT_REBIND_FN:
392 case LDAP_OPT_RESTART:
393 case LDAP_OPT_THREAD_FN_PTRS:
394 return LDAP_LOCAL_ERROR;
396 case LDAP_OPT_API_FEATURE_INFO:
397 case LDAP_OPT_API_INFO:
398 return LDAP_UNWILLING_TO_PERFORM;
400 case LDAP_OPT_AREC_EXCLUSIVE:
401 case LDAP_OPT_AUTO_RECONNECT:
402 case LDAP_OPT_CLIENT_CERTIFICATE:
403 case LDAP_OPT_DNSDOMAIN_NAME:
404 case LDAP_OPT_ENCRYPT:
405 case LDAP_OPT_ERROR_STRING:
406 case LDAP_OPT_FAST_CONCURRENT_BIND:
407 case LDAP_OPT_GETDSNAME_FLAGS:
408 case LDAP_OPT_HOST_NAME:
409 case LDAP_OPT_HOST_REACHABLE:
410 case LDAP_OPT_PING_KEEP_ALIVE:
411 case LDAP_OPT_PING_LIMIT:
412 case LDAP_OPT_PING_WAIT_TIME:
413 case LDAP_OPT_PROMPT_CREDENTIALS:
414 case LDAP_OPT_REF_DEREF_CONN_PER_MSG:
415 case LDAP_OPT_REFERRAL_CALLBACK:
416 case LDAP_OPT_REFERRAL_HOP_LIMIT:
417 case LDAP_OPT_ROOTDSE_CACHE:
418 case LDAP_OPT_SASL_METHOD:
419 case LDAP_OPT_SECURITY_CONTEXT:
420 case LDAP_OPT_SEND_TIMEOUT:
421 case LDAP_OPT_SERVER_CERTIFICATE:
422 case LDAP_OPT_SERVER_ERROR:
423 case LDAP_OPT_SERVER_EXT_ERROR:
426 case LDAP_OPT_SSL_INFO:
427 case LDAP_OPT_SSPI_FLAGS:
428 case LDAP_OPT_TCP_KEEPALIVE:
429 FIXME( "Unsupported option: 0x%02x\n", option );
430 return LDAP_NOT_SUPPORTED;
433 FIXME( "Unknown option: 0x%02x\n", option );
434 return LDAP_LOCAL_ERROR;