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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
24 #include "wine/debug.h"
35 #define LDAP_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
39 #include "winldap_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 /***********************************************************************
45 * ldap_control_freeA (WLDAP32.@)
47 * See ldap_control_freeW.
49 ULONG ldap_control_freeA( LDAPControlA *control )
51 ULONG ret = LDAP_SUCCESS;
54 TRACE( "(%p)\n", control );
55 controlfreeA( control );
61 /***********************************************************************
62 * ldap_control_freeW (WLDAP32.@)
64 * Free an LDAPControl structure.
67 * control [I] LDAPControl structure to free.
72 ULONG ldap_control_freeW( LDAPControlW *control )
74 ULONG ret = LDAP_SUCCESS;
77 TRACE( "(%p)\n", control );
78 controlfreeW( control );
84 /***********************************************************************
85 * ldap_controls_freeA (WLDAP32.@)
87 * See ldap_controls_freeW.
89 ULONG ldap_controls_freeA( LDAPControlA **controls )
91 ULONG ret = LDAP_SUCCESS;
94 TRACE( "(%p)\n", controls );
95 controlarrayfreeA( controls );
101 /***********************************************************************
102 * ldap_controls_freeW (WLDAP32.@)
104 * Free an array of LDAPControl structures.
107 * controls [I] Array of LDAPControl structures to free.
112 ULONG ldap_controls_freeW( LDAPControlW **controls )
114 ULONG ret = LDAP_SUCCESS;
117 TRACE( "(%p)\n", controls );
118 controlarrayfreeW( controls );
124 /***********************************************************************
125 * ldap_create_page_controlA (WLDAP32.@)
127 * See ldap_create_page_controlW.
129 ULONG ldap_create_page_controlA( WLDAP32_LDAP *ld, ULONG pagesize,
130 struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlA *control )
132 FIXME( "(%p, 0x%08lx, %p, 0x%02x, %p)\n", ld, pagesize, cookie,
134 return LDAP_NOT_SUPPORTED;
137 /***********************************************************************
138 * ldap_create_page_controlW (WLDAP32.@)
140 * Create a control for paged search results.
143 * ld [I] Pointer to an LDAP context.
144 * pagesize [I] Number of entries to return per page.
145 * cookie [I] Used by the server to track its location in the
147 * critical [I] Tells the server this control is critical to the
149 * control [O] LDAPControl created.
152 * Success: LDAP_SUCCESS
153 * Failure: An LDAP error code.
156 * Not implemented. It may be possible to implement this function
157 * on top of ldap_create_vlv_control.
159 ULONG ldap_create_page_controlW( WLDAP32_LDAP *ld, ULONG pagesize,
160 struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlW *control )
162 FIXME( "(%p, 0x%08lx, %p, 0x%02x, %p)\n", ld, pagesize, cookie,
164 return LDAP_NOT_SUPPORTED;
167 /***********************************************************************
168 * ldap_create_sort_controlA (WLDAP32.@)
170 * See ldap_create_sort_controlW.
172 ULONG ldap_create_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkey,
173 UCHAR critical, PLDAPControlA *control )
175 ULONG ret = LDAP_NOT_SUPPORTED;
177 LDAPSortKeyW **sortkeyW = NULL;
178 LDAPControlW *controlW = NULL;
180 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
182 if (!ld || !sortkey || !control)
183 return WLDAP32_LDAP_PARAM_ERROR;
185 sortkeyW = sortkeyarrayAtoW( sortkey );
186 if (!sortkeyW) return WLDAP32_LDAP_NO_MEMORY;
188 ret = ldap_create_sort_controlW( ld, sortkeyW, critical, &controlW );
190 *control = controlWtoA( controlW );
191 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
193 ldap_control_freeW( controlW );
194 sortkeyarrayfreeW( sortkeyW );
200 /***********************************************************************
201 * ldap_create_sort_controlW (WLDAP32.@)
203 * Create a control for server sorted search results.
206 * ld [I] Pointer to an LDAP context.
207 * sortkey [I] Array of LDAPSortKey structures, each specifying an
208 * attribute to use as a sort key, a matching rule and
209 * the sort order (ascending or descending).
210 * critical [I] Tells the server this control is critical to the
212 * control [O] LDAPControl created.
215 * Success: LDAP_SUCCESS
216 * Failure: An LDAP error code.
219 * Pass the created control as a server control in subsequent calls
220 * to ldap_search_ext(_s) to obtain sorted search results.
222 ULONG ldap_create_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkey,
223 UCHAR critical, PLDAPControlW *control )
225 ULONG ret = LDAP_NOT_SUPPORTED;
227 LDAPSortKey **sortkeyU = NULL;
228 LDAPControl *controlU = NULL;
230 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
232 if (!ld || !sortkey || !control)
233 return WLDAP32_LDAP_PARAM_ERROR;
235 sortkeyU = sortkeyarrayWtoU( sortkey );
236 if (!sortkeyU) return WLDAP32_LDAP_NO_MEMORY;
238 ret = ldap_create_sort_control( ld, sortkeyU, critical, &controlU );
240 *control = controlUtoW( controlU );
241 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
243 ldap_control_free( controlU );
244 sortkeyarrayfreeU( sortkeyU );
250 /***********************************************************************
251 * ldap_create_vlv_controlA (WLDAP32.@)
253 * See ldap_create_vlv_controlW.
255 INT ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
256 UCHAR critical, LDAPControlA **control )
258 INT ret = LDAP_NOT_SUPPORTED;
260 LDAPControlW **controlW = NULL;
262 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
264 if (!ld) return ~0UL;
266 ret = ldap_create_vlv_controlW( ld, info, critical, controlW );
268 *control = controlWtoA( *controlW );
269 ldap_control_freeW( *controlW );
275 /***********************************************************************
276 * ldap_create_vlv_controlW (WLDAP32.@)
278 * Create a virtual list view control.
281 * ld [I] Pointer to an LDAP context.
282 * info [I] LDAPVLVInfo structure specifying a list view window.
283 * critical [I] Tells the server this control is critical to the
285 * control [O] LDAPControl created.
288 * Success: LDAP_SUCCESS
289 * Failure: An LDAP error code.
292 * Pass the created control in conjuction with a sort control as
293 * server controls in subsequent calls to ldap_search_ext(_s). The
294 * server will then return a sorted, contiguous subset of results
295 * that meets the criteria specified in the LDAPVLVInfo structure.
297 INT ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
298 UCHAR critical, LDAPControlW **control )
300 INT ret = LDAP_NOT_SUPPORTED;
302 LDAPControl **controlU = NULL;
304 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
306 if (!ld) return ~0UL;
308 ret = ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, controlU );
310 *control = controlUtoW( *controlU );
311 ldap_control_free( *controlU );
317 /***********************************************************************
318 * ldap_encode_sort_controlA (WLDAP32.@)
320 * See ldap_encode_sort_controlW.
322 ULONG ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys,
323 PLDAPControlA control, BOOLEAN critical )
325 return ldap_create_sort_controlA( ld, sortkeys, critical, &control );
328 /***********************************************************************
329 * ldap_encode_sort_controlW (WLDAP32.@)
331 * Create a control for server sorted search results.
334 * ld [I] Pointer to an LDAP context.
335 * sortkey [I] Array of LDAPSortKey structures, each specifying an
336 * attribute to use as a sort key, a matching rule and
337 * the sort order (ascending or descending).
338 * critical [I] Tells the server this control is critical to the
340 * control [O] LDAPControl created.
343 * Success: LDAP_SUCCESS
344 * Failure: An LDAP error code.
347 * This function is obsolete. Use its equivalent
348 * ldap_create_sort_control instead.
350 ULONG ldap_encode_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkeys,
351 PLDAPControlW control, BOOLEAN critical )
353 return ldap_create_sort_controlW( ld, sortkeys, critical, &control );
356 /***********************************************************************
357 * ldap_free_controlsA (WLDAP32.@)
359 * See ldap_free_controlsW.
361 ULONG ldap_free_controlsA( LDAPControlA **controls )
363 return ldap_controls_freeA( controls );
366 /***********************************************************************
367 * ldap_free_controlsW (WLDAP32.@)
369 * Free an array of LDAPControl structures.
372 * controls [I] Array of LDAPControl structures to free.
378 * Obsolete, use ldap_controls_freeW.
380 ULONG ldap_free_controlsW( LDAPControlW **controls )
382 return ldap_controls_freeW( controls );