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_rename_extA (WLDAP32.@)
44 * See ldap_rename_extW.
46 ULONG CDECL ldap_rename_extA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
47 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
48 PLDAPControlA *clientctrls, ULONG *message )
50 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
52 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
53 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
55 ret = WLDAP32_LDAP_NO_MEMORY;
57 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_a(dn),
58 debugstr_a(newrdn), debugstr_a(newparent), delete,
59 serverctrls, clientctrls, message );
61 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
68 newrdnW = strAtoW( newrdn );
69 if (!newrdnW) goto exit;
72 newparentW = strAtoW( newparent );
73 if (!newparentW) goto exit;
76 serverctrlsW = controlarrayAtoW( serverctrls );
77 if (!serverctrlsW) goto exit;
80 clientctrlsW = controlarrayAtoW( clientctrls );
81 if (!clientctrlsW) goto exit;
84 ret = ldap_rename_extW( ld, dnW, newrdnW, newparentW, delete,
85 serverctrlsW, clientctrlsW, message );
90 strfreeW( newparentW );
91 controlarrayfreeW( serverctrlsW );
92 controlarrayfreeW( clientctrlsW );
98 /***********************************************************************
99 * ldap_rename_extW (WLDAP32.@)
101 * Change the DN of a directory entry (asynchronous operation).
104 * ld [I] Pointer to an LDAP context.
105 * dn [I] DN of the entry to change.
106 * newrdn [I] New RDN for the entry.
107 * newparent [I] New parent for the entry.
108 * delete [I] Delete old RDN?
109 * serverctrls [I] Array of LDAP server controls.
110 * clientctrls [I] Array of LDAP client controls.
111 * message [O] Message ID of the operation.
114 * Success: LDAP_SUCCESS
115 * Failure: An LDAP error code.
118 * Call ldap_result with the message ID to get the result of
119 * the operation. Cancel the operation by calling ldap_abandon
120 * with the message ID.
122 ULONG CDECL ldap_rename_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
123 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
124 PLDAPControlW *clientctrls, ULONG *message )
126 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
128 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
129 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
131 ret = WLDAP32_LDAP_NO_MEMORY;
133 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_w(dn),
134 debugstr_w(newrdn), debugstr_w(newparent), delete,
135 serverctrls, clientctrls, message );
137 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
144 newrdnU = strWtoU( newrdn );
145 if (!newrdnU) goto exit;
148 newparentU = strWtoU( newparent );
149 if (!newparentU) goto exit;
152 serverctrlsU = controlarrayWtoU( serverctrls );
153 if (!serverctrlsU) goto exit;
156 clientctrlsU = controlarrayWtoU( clientctrls );
157 if (!clientctrlsU) goto exit;
160 ret = map_error( ldap_rename( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
161 delete, serverctrlsU, clientctrlsU, (int *)message ));
166 strfreeU( newparentU );
167 controlarrayfreeU( serverctrlsU );
168 controlarrayfreeU( clientctrlsU );
174 /***********************************************************************
175 * ldap_rename_ext_sA (WLDAP32.@)
177 * See ldap_rename_ext_sW.
179 ULONG CDECL ldap_rename_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
180 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
181 PLDAPControlA *clientctrls )
183 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
185 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
186 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
188 ret = WLDAP32_LDAP_NO_MEMORY;
190 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_a(dn),
191 debugstr_a(newrdn), debugstr_a(newparent), delete,
192 serverctrls, clientctrls );
194 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
201 newrdnW = strAtoW( newrdn );
202 if (!newrdnW) goto exit;
205 newparentW = strAtoW( newparent );
206 if (!newparentW) goto exit;
209 serverctrlsW = controlarrayAtoW( serverctrls );
210 if (!serverctrlsW) goto exit;
213 clientctrlsW = controlarrayAtoW( clientctrls );
214 if (!clientctrlsW) goto exit;
217 ret = ldap_rename_ext_sW( ld, dnW, newrdnW, newparentW, delete,
218 serverctrlsW, clientctrlsW );
223 strfreeW( newparentW );
224 controlarrayfreeW( serverctrlsW );
225 controlarrayfreeW( clientctrlsW );
230 /***********************************************************************
231 * ldap_rename_ext_sW (WLDAP32.@)
233 * Change the DN of a directory entry (synchronous operation).
236 * ld [I] Pointer to an LDAP context.
237 * dn [I] DN of the entry to change.
238 * newrdn [I] New RDN for the entry.
239 * newparent [I] New parent for the entry.
240 * delete [I] Delete old RDN?
241 * serverctrls [I] Array of LDAP server controls.
242 * clientctrls [I] Array of LDAP client controls.
245 * Success: LDAP_SUCCESS
246 * Failure: An LDAP error code.
248 ULONG CDECL ldap_rename_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
249 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
250 PLDAPControlW *clientctrls )
252 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
254 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
255 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
257 ret = WLDAP32_LDAP_NO_MEMORY;
259 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_w(dn),
260 debugstr_w(newrdn), debugstr_w(newparent), delete,
261 serverctrls, clientctrls );
263 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
270 newrdnU = strWtoU( newrdn );
271 if (!newrdnU) goto exit;
274 newparentU = strWtoU( newparent );
275 if (!newparentU) goto exit;
278 serverctrlsU = controlarrayWtoU( serverctrls );
279 if (!serverctrlsU) goto exit;
282 clientctrlsU = controlarrayWtoU( clientctrls );
283 if (!clientctrlsU) goto exit;
286 ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
287 delete, serverctrlsU, clientctrlsU ));
292 strfreeU( newparentU );
293 controlarrayfreeU( serverctrlsU );
294 controlarrayfreeU( clientctrlsU );