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_sort_controlA (WLDAP32.@)
127 * See ldap_create_sort_controlW.
129 ULONG ldap_create_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkey,
130 UCHAR critical, PLDAPControlA *control )
132 ULONG ret = LDAP_NOT_SUPPORTED;
134 LDAPSortKeyW **sortkeyW = NULL;
135 LDAPControlW *controlW = NULL;
137 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
139 if (!ld || !sortkey || !control)
140 return WLDAP32_LDAP_PARAM_ERROR;
142 sortkeyW = sortkeyarrayAtoW( sortkey );
143 if (!sortkeyW) return WLDAP32_LDAP_NO_MEMORY;
145 ret = ldap_create_sort_controlW( ld, sortkeyW, critical, &controlW );
147 *control = controlWtoA( controlW );
148 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
150 ldap_control_freeW( controlW );
151 sortkeyarrayfreeW( sortkeyW );
157 /***********************************************************************
158 * ldap_create_sort_controlW (WLDAP32.@)
160 * Create a control for server sorted search results.
163 * ld [I] Pointer to an LDAP context.
164 * sortkey [I] Array of LDAPSortKey structures, each specifying an
165 * attribute to use as a sort key, a matching rule and
166 * the sort order (ascending or descending).
167 * critical [I] Tells the server this control is critical to the
169 * control [O] LDAPControl created.
172 * Success: LDAP_SUCCESS
173 * Failure: An LDAP error code.
176 * Pass the created control as a server control in subsequent calls
177 * to ldap_search_ext(_s) to obtain sorted search results.
179 ULONG ldap_create_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkey,
180 UCHAR critical, PLDAPControlW *control )
182 ULONG ret = LDAP_NOT_SUPPORTED;
184 LDAPSortKey **sortkeyU = NULL;
185 LDAPControl *controlU = NULL;
187 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
189 if (!ld || !sortkey || !control)
190 return WLDAP32_LDAP_PARAM_ERROR;
192 sortkeyU = sortkeyarrayWtoU( sortkey );
193 if (!sortkeyU) return WLDAP32_LDAP_NO_MEMORY;
195 ret = ldap_create_sort_control( ld, sortkeyU, critical, &controlU );
197 *control = controlUtoW( controlU );
198 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
200 ldap_control_free( controlU );
201 sortkeyarrayfreeU( sortkeyU );
207 /***********************************************************************
208 * ldap_create_vlv_controlA (WLDAP32.@)
210 * See ldap_create_vlv_controlW.
212 INT ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
213 UCHAR critical, LDAPControlA **control )
215 INT ret = LDAP_NOT_SUPPORTED;
217 LDAPControlW **controlW = NULL;
219 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
221 if (!ld) return ~0UL;
223 ret = ldap_create_vlv_controlW( ld, info, critical, controlW );
225 *control = controlWtoA( *controlW );
226 ldap_control_freeW( *controlW );
232 /***********************************************************************
233 * ldap_create_vlv_controlW (WLDAP32.@)
235 * Create a virtual list view control.
238 * ld [I] Pointer to an LDAP context.
239 * info [I] LDAPVLVInfo structure specifying a list view window.
240 * critical [I] Tells the server this control is critical to the
242 * control [O] LDAPControl created.
245 * Success: LDAP_SUCCESS
246 * Failure: An LDAP error code.
249 * Pass the created control in conjuction with a sort control as
250 * server controls in subsequent calls to ldap_search_ext(_s). The
251 * server will then return a sorted, contiguous subset of results
252 * that meets the criteria specified in the LDAPVLVInfo structure.
254 INT ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
255 UCHAR critical, LDAPControlW **control )
257 INT ret = LDAP_NOT_SUPPORTED;
259 LDAPControl **controlU = NULL;
261 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
263 if (!ld) return ~0UL;
265 ret = ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, controlU );
267 *control = controlUtoW( *controlU );
268 ldap_control_free( *controlU );
274 /***********************************************************************
275 * ldap_encode_sort_controlA (WLDAP32.@)
277 * See ldap_encode_sort_controlW.
279 ULONG ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys,
280 PLDAPControlA control, BOOLEAN critical )
282 return ldap_create_sort_controlA( ld, sortkeys, critical, &control );
285 /***********************************************************************
286 * ldap_encode_sort_controlW (WLDAP32.@)
288 * Create a control for server sorted search results.
291 * ld [I] Pointer to an LDAP context.
292 * sortkey [I] Array of LDAPSortKey structures, each specifying an
293 * attribute to use as a sort key, a matching rule and
294 * the sort order (ascending or descending).
295 * critical [I] Tells the server this control is critical to the
297 * control [O] LDAPControl created.
300 * Success: LDAP_SUCCESS
301 * Failure: An LDAP error code.
304 * This function is obsolete. Use its equivalent
305 * ldap_create_sort_control instead.
307 ULONG ldap_encode_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkeys,
308 PLDAPControlW control, BOOLEAN critical )
310 return ldap_create_sort_controlW( ld, sortkeys, critical, &control );
313 /***********************************************************************
314 * ldap_free_controlsA (WLDAP32.@)
316 * See ldap_free_controlsW.
318 ULONG ldap_free_controlsA( LDAPControlA **controls )
320 return ldap_controls_freeA( controls );
323 /***********************************************************************
324 * ldap_free_controlsW (WLDAP32.@)
326 * Free an array of LDAPControl structures.
329 * controls [I] Array of LDAPControl structures to free.
335 * Obsolete, use ldap_controls_freeW.
337 ULONG ldap_free_controlsW( LDAPControlW **controls )
339 return ldap_controls_freeW( controls );