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_modrdnA (WLDAP32.@)
44 ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
46 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
48 WCHAR *dnW = NULL, *newdnW = NULL;
50 ret = WLDAP32_LDAP_NO_MEMORY;
52 TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
54 if (!ld || !newdn) return ~0u;
61 newdnW = strAtoW( newdn );
62 if (!newdnW) goto exit;
64 ret = ldap_modrdnW( ld, dnW, newdnW );
74 /***********************************************************************
75 * ldap_modrdnW (WLDAP32.@)
77 * Change the RDN of a directory entry (asynchronous operation).
80 * ld [I] Pointer to an LDAP context.
81 * dn [I] DN of the entry to change.
82 * newdn [I] New DN for the entry.
85 * Success: Message ID of the modrdn operation.
86 * Failure: An LDAP error code.
89 * Call ldap_result with the message ID to get the result of
90 * the operation. Cancel the operation by calling ldap_abandon
91 * with the message ID.
93 ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
95 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
97 char *dnU = NULL, *newdnU = NULL;
100 ret = WLDAP32_LDAP_NO_MEMORY;
102 TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
104 if (!ld || !newdn) return ~0u;
111 newdnU = strWtoU( newdn );
112 if (!newdnU) goto exit;
114 ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
116 if (ret == LDAP_SUCCESS)
129 /***********************************************************************
130 * ldap_modrdn2A (WLDAP32.@)
134 ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
136 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
138 WCHAR *dnW = NULL, *newdnW = NULL;
140 ret = WLDAP32_LDAP_NO_MEMORY;
142 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
144 if (!ld || !newdn) return ~0u;
151 newdnW = strAtoW( newdn );
152 if (!newdnW) goto exit;
154 ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
164 /***********************************************************************
165 * ldap_modrdn2W (WLDAP32.@)
167 * Change the RDN of a directory entry (asynchronous operation).
170 * ld [I] Pointer to an LDAP context.
171 * dn [I] DN of the entry to change.
172 * newdn [I] New DN for the entry.
173 * delete [I] Delete old DN?
176 * Success: Message ID of the modrdn operation.
177 * Failure: An LDAP error code.
180 * Call ldap_result with the message ID to get the result of
181 * the operation. Cancel the operation by calling ldap_abandon
182 * with the message ID.
184 ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
186 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
188 char *dnU = NULL, *newdnU = NULL;
191 ret = WLDAP32_LDAP_NO_MEMORY;
193 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
195 if (!ld || !newdn) return ~0u;
202 newdnU = strWtoU( newdn );
203 if (!newdnU) goto exit;
205 ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
207 if (ret == LDAP_SUCCESS)
220 /***********************************************************************
221 * ldap_modrdn2_sA (WLDAP32.@)
223 * See ldap_modrdn2_sW.
225 ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
227 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
229 WCHAR *dnW = NULL, *newdnW = NULL;
231 ret = WLDAP32_LDAP_NO_MEMORY;
233 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
235 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
242 newdnW = strAtoW( newdn );
243 if (!newdnW) goto exit;
245 ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
255 /***********************************************************************
256 * ldap_modrdn2_sW (WLDAP32.@)
258 * Change the RDN of a directory entry (synchronous operation).
261 * ld [I] Pointer to an LDAP context.
262 * dn [I] DN of the entry to change.
263 * newdn [I] New DN for the entry.
264 * delete [I] Delete old DN?
267 * Success: LDAP_SUCCESS
268 * Failure: An LDAP error code.
270 ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
272 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
274 char *dnU = NULL, *newdnU = NULL;
276 ret = WLDAP32_LDAP_NO_MEMORY;
278 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
280 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
287 newdnU = strWtoU( newdn );
288 if (!newdnU) goto exit;
290 ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL ));
300 /***********************************************************************
301 * ldap_modrdn_sA (WLDAP32.@)
303 * See ldap_modrdn_sW.
305 ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
307 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
309 WCHAR *dnW = NULL, *newdnW = NULL;
311 ret = WLDAP32_LDAP_NO_MEMORY;
313 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
315 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
322 newdnW = strAtoW( newdn );
323 if (!newdnW) goto exit;
325 ret = ldap_modrdn_sW( ld, dnW, newdnW );
335 /***********************************************************************
336 * ldap_modrdn_sW (WLDAP32.@)
338 * Change the RDN of a directory entry (synchronous operation).
341 * ld [I] Pointer to an LDAP context.
342 * dn [I] DN of the entry to change.
343 * newdn [I] New DN for the entry.
346 * Success: LDAP_SUCCESS
347 * Failure: An LDAP error code.
349 ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
351 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
353 char *dnU = NULL, *newdnU = NULL;
355 ret = WLDAP32_LDAP_NO_MEMORY;
357 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
359 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
366 newdnU = strWtoU( newdn );
367 if (!newdnU) goto exit;
369 ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL ));