push b72af2511d67bded8ece08d825ff0eb4a60c20a6
[wine/hacks.git] / dlls / wldap32 / rename.c
blob47842b5d68b3fe5652f24b3e39f960d8e566ecb1
1 /*
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
21 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_NOT_SUPPORTED 0x5c
36 #endif
38 #include "winldap_private.h"
39 #include "wldap32.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43 /***********************************************************************
44 * ldap_rename_extA (WLDAP32.@)
46 * See ldap_rename_extW.
48 ULONG CDECL ldap_rename_extA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
49 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
50 PLDAPControlA *clientctrls, ULONG *message )
52 ULONG ret = LDAP_NOT_SUPPORTED;
53 #ifdef HAVE_LDAP
54 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
55 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
57 ret = WLDAP32_LDAP_NO_MEMORY;
59 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_a(dn),
60 debugstr_a(newrdn), debugstr_a(newparent), delete,
61 serverctrls, clientctrls, message );
63 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
65 if (dn) {
66 dnW = strAtoW( dn );
67 if (!dnW) goto exit;
69 if (newrdn) {
70 newrdnW = strAtoW( newrdn );
71 if (!newrdnW) goto exit;
73 if (newparent) {
74 newparentW = strAtoW( newparent );
75 if (!newparentW) goto exit;
77 if (serverctrls) {
78 serverctrlsW = controlarrayAtoW( serverctrls );
79 if (!serverctrlsW) goto exit;
81 if (clientctrls) {
82 clientctrlsW = controlarrayAtoW( clientctrls );
83 if (!clientctrlsW) goto exit;
86 ret = ldap_rename_extW( ld, dnW, newrdnW, newparentW, delete,
87 serverctrlsW, clientctrlsW, message );
89 exit:
90 strfreeW( dnW );
91 strfreeW( newrdnW );
92 strfreeW( newparentW );
93 controlarrayfreeW( serverctrlsW );
94 controlarrayfreeW( clientctrlsW );
96 #endif
97 return ret;
100 /***********************************************************************
101 * ldap_rename_extW (WLDAP32.@)
103 * Change the DN of a directory entry (asynchronous operation).
105 * PARAMS
106 * ld [I] Pointer to an LDAP context.
107 * dn [I] DN of the entry to change.
108 * newrdn [I] New RDN for the entry.
109 * newparent [I] New parent for the entry.
110 * delete [I] Delete old RDN?
111 * serverctrls [I] Array of LDAP server controls.
112 * clientctrls [I] Array of LDAP client controls.
113 * message [O] Message ID of the operation.
115 * RETURNS
116 * Success: LDAP_SUCCESS
117 * Failure: An LDAP error code.
119 * NOTES
120 * Call ldap_result with the message ID to get the result of
121 * the operation. Cancel the operation by calling ldap_abandon
122 * with the message ID.
124 ULONG CDECL ldap_rename_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
125 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
126 PLDAPControlW *clientctrls, ULONG *message )
128 ULONG ret = LDAP_NOT_SUPPORTED;
129 #ifdef HAVE_LDAP
130 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
131 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
133 ret = WLDAP32_LDAP_NO_MEMORY;
135 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_w(dn),
136 debugstr_w(newrdn), debugstr_w(newparent), delete,
137 serverctrls, clientctrls, message );
139 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
141 if (dn) {
142 dnU = strWtoU( dn );
143 if (!dnU) goto exit;
145 if (newrdn) {
146 newrdnU = strWtoU( newrdn );
147 if (!newrdnU) goto exit;
149 if (newparent) {
150 newparentU = strWtoU( newparent );
151 if (!newparentU) goto exit;
153 if (serverctrls) {
154 serverctrlsU = controlarrayWtoU( serverctrls );
155 if (!serverctrlsU) goto exit;
157 if (clientctrls) {
158 clientctrlsU = controlarrayWtoU( clientctrls );
159 if (!clientctrlsU) goto exit;
162 ret = ldap_rename( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
163 delete, serverctrlsU, clientctrlsU, (int *)message );
165 exit:
166 strfreeU( dnU );
167 strfreeU( newrdnU );
168 strfreeU( newparentU );
169 controlarrayfreeU( serverctrlsU );
170 controlarrayfreeU( clientctrlsU );
172 #endif
173 return ret;
176 /***********************************************************************
177 * ldap_rename_ext_sA (WLDAP32.@)
179 * See ldap_rename_ext_sW.
181 ULONG CDECL ldap_rename_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
182 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
183 PLDAPControlA *clientctrls )
185 ULONG ret = LDAP_NOT_SUPPORTED;
186 #ifdef HAVE_LDAP
187 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
188 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
190 ret = WLDAP32_LDAP_NO_MEMORY;
192 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_a(dn),
193 debugstr_a(newrdn), debugstr_a(newparent), delete,
194 serverctrls, clientctrls );
196 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
198 if (dn) {
199 dnW = strAtoW( dn );
200 if (!dnW) goto exit;
202 if (newrdn) {
203 newrdnW = strAtoW( newrdn );
204 if (!newrdnW) goto exit;
206 if (newparent) {
207 newparentW = strAtoW( newparent );
208 if (!newparentW) goto exit;
210 if (serverctrls) {
211 serverctrlsW = controlarrayAtoW( serverctrls );
212 if (!serverctrlsW) goto exit;
214 if (clientctrls) {
215 clientctrlsW = controlarrayAtoW( clientctrls );
216 if (!clientctrlsW) goto exit;
219 ret = ldap_rename_ext_sW( ld, dnW, newrdnW, newparentW, delete,
220 serverctrlsW, clientctrlsW );
222 exit:
223 strfreeW( dnW );
224 strfreeW( newrdnW );
225 strfreeW( newparentW );
226 controlarrayfreeW( serverctrlsW );
227 controlarrayfreeW( clientctrlsW );
229 #endif
230 return ret;
232 /***********************************************************************
233 * ldap_rename_ext_sW (WLDAP32.@)
235 * Change the DN of a directory entry (synchronous operation).
237 * PARAMS
238 * ld [I] Pointer to an LDAP context.
239 * dn [I] DN of the entry to change.
240 * newrdn [I] New RDN for the entry.
241 * newparent [I] New parent for the entry.
242 * delete [I] Delete old RDN?
243 * serverctrls [I] Array of LDAP server controls.
244 * clientctrls [I] Array of LDAP client controls.
246 * RETURNS
247 * Success: LDAP_SUCCESS
248 * Failure: An LDAP error code.
250 ULONG CDECL ldap_rename_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
251 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
252 PLDAPControlW *clientctrls )
254 ULONG ret = LDAP_NOT_SUPPORTED;
255 #ifdef HAVE_LDAP
256 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
257 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
259 ret = WLDAP32_LDAP_NO_MEMORY;
261 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_w(dn),
262 debugstr_w(newrdn), debugstr_w(newparent), delete,
263 serverctrls, clientctrls );
265 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
267 if (dn) {
268 dnU = strWtoU( dn );
269 if (!dnU) goto exit;
271 if (newrdn) {
272 newrdnU = strWtoU( newrdn );
273 if (!newrdnU) goto exit;
275 if (newparent) {
276 newparentU = strWtoU( newparent );
277 if (!newparentU) goto exit;
279 if (serverctrls) {
280 serverctrlsU = controlarrayWtoU( serverctrls );
281 if (!serverctrlsU) goto exit;
283 if (clientctrls) {
284 clientctrlsU = controlarrayWtoU( clientctrls );
285 if (!clientctrlsU) goto exit;
288 ret = ldap_rename_s( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
289 delete, serverctrlsU, clientctrlsU );
291 exit:
292 strfreeU( dnU );
293 strfreeU( newrdnU );
294 strfreeU( newparentU );
295 controlarrayfreeU( serverctrlsU );
296 controlarrayfreeU( clientctrlsU );
298 #endif
299 return ret;