shell32: Add printers CLSID to test, clean up a bit.
[wine/testsucceed.git] / dlls / wldap32 / rename.c
blob864a6af31ae4201b07a282da205891e83123c8e4
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 #endif
36 #include "winldap_private.h"
37 #include "wldap32.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;
51 #ifdef HAVE_LDAP
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;
63 if (dn) {
64 dnW = strAtoW( dn );
65 if (!dnW) goto exit;
67 if (newrdn) {
68 newrdnW = strAtoW( newrdn );
69 if (!newrdnW) goto exit;
71 if (newparent) {
72 newparentW = strAtoW( newparent );
73 if (!newparentW) goto exit;
75 if (serverctrls) {
76 serverctrlsW = controlarrayAtoW( serverctrls );
77 if (!serverctrlsW) goto exit;
79 if (clientctrls) {
80 clientctrlsW = controlarrayAtoW( clientctrls );
81 if (!clientctrlsW) goto exit;
84 ret = ldap_rename_extW( ld, dnW, newrdnW, newparentW, delete,
85 serverctrlsW, clientctrlsW, message );
87 exit:
88 strfreeW( dnW );
89 strfreeW( newrdnW );
90 strfreeW( newparentW );
91 controlarrayfreeW( serverctrlsW );
92 controlarrayfreeW( clientctrlsW );
94 #endif
95 return ret;
98 /***********************************************************************
99 * ldap_rename_extW (WLDAP32.@)
101 * Change the DN of a directory entry (asynchronous operation).
103 * PARAMS
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.
113 * RETURNS
114 * Success: LDAP_SUCCESS
115 * Failure: An LDAP error code.
117 * NOTES
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;
127 #ifdef HAVE_LDAP
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;
139 if (dn) {
140 dnU = strWtoU( dn );
141 if (!dnU) goto exit;
143 if (newrdn) {
144 newrdnU = strWtoU( newrdn );
145 if (!newrdnU) goto exit;
147 if (newparent) {
148 newparentU = strWtoU( newparent );
149 if (!newparentU) goto exit;
151 if (serverctrls) {
152 serverctrlsU = controlarrayWtoU( serverctrls );
153 if (!serverctrlsU) goto exit;
155 if (clientctrls) {
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 ));
163 exit:
164 strfreeU( dnU );
165 strfreeU( newrdnU );
166 strfreeU( newparentU );
167 controlarrayfreeU( serverctrlsU );
168 controlarrayfreeU( clientctrlsU );
170 #endif
171 return ret;
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;
184 #ifdef HAVE_LDAP
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;
196 if (dn) {
197 dnW = strAtoW( dn );
198 if (!dnW) goto exit;
200 if (newrdn) {
201 newrdnW = strAtoW( newrdn );
202 if (!newrdnW) goto exit;
204 if (newparent) {
205 newparentW = strAtoW( newparent );
206 if (!newparentW) goto exit;
208 if (serverctrls) {
209 serverctrlsW = controlarrayAtoW( serverctrls );
210 if (!serverctrlsW) goto exit;
212 if (clientctrls) {
213 clientctrlsW = controlarrayAtoW( clientctrls );
214 if (!clientctrlsW) goto exit;
217 ret = ldap_rename_ext_sW( ld, dnW, newrdnW, newparentW, delete,
218 serverctrlsW, clientctrlsW );
220 exit:
221 strfreeW( dnW );
222 strfreeW( newrdnW );
223 strfreeW( newparentW );
224 controlarrayfreeW( serverctrlsW );
225 controlarrayfreeW( clientctrlsW );
227 #endif
228 return ret;
230 /***********************************************************************
231 * ldap_rename_ext_sW (WLDAP32.@)
233 * Change the DN of a directory entry (synchronous operation).
235 * PARAMS
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.
244 * RETURNS
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;
253 #ifdef HAVE_LDAP
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;
265 if (dn) {
266 dnU = strWtoU( dn );
267 if (!dnU) goto exit;
269 if (newrdn) {
270 newrdnU = strWtoU( newrdn );
271 if (!newrdnU) goto exit;
273 if (newparent) {
274 newparentU = strWtoU( newparent );
275 if (!newparentU) goto exit;
277 if (serverctrls) {
278 serverctrlsU = controlarrayWtoU( serverctrls );
279 if (!serverctrlsU) goto exit;
281 if (clientctrls) {
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 ));
289 exit:
290 strfreeU( dnU );
291 strfreeU( newrdnU );
292 strfreeU( newparentU );
293 controlarrayfreeU( serverctrlsU );
294 controlarrayfreeU( clientctrlsU );
296 #endif
297 return ret;