ddraw/tests: Recognise E_NOTIMPL returned from UpdateOverlay() on VMware as broken.
[wine.git] / dlls / wldap32 / rename.c
blob2de50818b7452e7a8408031972ec757f18dafdf6
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"
22 #include "wine/port.h"
24 #include <stdarg.h>
25 #ifdef HAVE_LDAP_H
26 #include <ldap.h>
27 #endif
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
33 #include "winldap_private.h"
34 #include "wldap32.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
39 /***********************************************************************
40 * ldap_rename_extA (WLDAP32.@)
42 * See ldap_rename_extW.
44 ULONG CDECL ldap_rename_extA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
45 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
46 PLDAPControlA *clientctrls, ULONG *message )
48 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
49 #ifdef HAVE_LDAP
50 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
51 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
53 ret = WLDAP32_LDAP_NO_MEMORY;
55 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_a(dn),
56 debugstr_a(newrdn), debugstr_a(newparent), delete,
57 serverctrls, clientctrls, message );
59 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
61 if (dn) {
62 dnW = strAtoW( dn );
63 if (!dnW) goto exit;
65 if (newrdn) {
66 newrdnW = strAtoW( newrdn );
67 if (!newrdnW) goto exit;
69 if (newparent) {
70 newparentW = strAtoW( newparent );
71 if (!newparentW) goto exit;
73 if (serverctrls) {
74 serverctrlsW = controlarrayAtoW( serverctrls );
75 if (!serverctrlsW) goto exit;
77 if (clientctrls) {
78 clientctrlsW = controlarrayAtoW( clientctrls );
79 if (!clientctrlsW) goto exit;
82 ret = ldap_rename_extW( ld, dnW, newrdnW, newparentW, delete,
83 serverctrlsW, clientctrlsW, message );
85 exit:
86 strfreeW( dnW );
87 strfreeW( newrdnW );
88 strfreeW( newparentW );
89 controlarrayfreeW( serverctrlsW );
90 controlarrayfreeW( clientctrlsW );
92 #endif
93 return ret;
96 /***********************************************************************
97 * ldap_rename_extW (WLDAP32.@)
99 * Change the DN of a directory entry (asynchronous operation).
101 * PARAMS
102 * ld [I] Pointer to an LDAP context.
103 * dn [I] DN of the entry to change.
104 * newrdn [I] New RDN for the entry.
105 * newparent [I] New parent for the entry.
106 * delete [I] Delete old RDN?
107 * serverctrls [I] Array of LDAP server controls.
108 * clientctrls [I] Array of LDAP client controls.
109 * message [O] Message ID of the operation.
111 * RETURNS
112 * Success: LDAP_SUCCESS
113 * Failure: An LDAP error code.
115 * NOTES
116 * Call ldap_result with the message ID to get the result of
117 * the operation. Cancel the operation by calling ldap_abandon
118 * with the message ID.
120 ULONG CDECL ldap_rename_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
121 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
122 PLDAPControlW *clientctrls, ULONG *message )
124 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
125 #ifdef HAVE_LDAP
126 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
127 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
129 ret = WLDAP32_LDAP_NO_MEMORY;
131 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_w(dn),
132 debugstr_w(newrdn), debugstr_w(newparent), delete,
133 serverctrls, clientctrls, message );
135 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
137 if (dn) {
138 dnU = strWtoU( dn );
139 if (!dnU) goto exit;
141 if (newrdn) {
142 newrdnU = strWtoU( newrdn );
143 if (!newrdnU) goto exit;
145 if (newparent) {
146 newparentU = strWtoU( newparent );
147 if (!newparentU) goto exit;
149 if (serverctrls) {
150 serverctrlsU = controlarrayWtoU( serverctrls );
151 if (!serverctrlsU) goto exit;
153 if (clientctrls) {
154 clientctrlsU = controlarrayWtoU( clientctrls );
155 if (!clientctrlsU) goto exit;
158 ret = map_error( ldap_rename( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
159 delete, serverctrlsU, clientctrlsU, (int *)message ));
161 exit:
162 strfreeU( dnU );
163 strfreeU( newrdnU );
164 strfreeU( newparentU );
165 controlarrayfreeU( serverctrlsU );
166 controlarrayfreeU( clientctrlsU );
168 #endif
169 return ret;
172 /***********************************************************************
173 * ldap_rename_ext_sA (WLDAP32.@)
175 * See ldap_rename_ext_sW.
177 ULONG CDECL ldap_rename_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
178 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
179 PLDAPControlA *clientctrls )
181 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
182 #ifdef HAVE_LDAP
183 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
184 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
186 ret = WLDAP32_LDAP_NO_MEMORY;
188 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_a(dn),
189 debugstr_a(newrdn), debugstr_a(newparent), delete,
190 serverctrls, clientctrls );
192 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
194 if (dn) {
195 dnW = strAtoW( dn );
196 if (!dnW) goto exit;
198 if (newrdn) {
199 newrdnW = strAtoW( newrdn );
200 if (!newrdnW) goto exit;
202 if (newparent) {
203 newparentW = strAtoW( newparent );
204 if (!newparentW) goto exit;
206 if (serverctrls) {
207 serverctrlsW = controlarrayAtoW( serverctrls );
208 if (!serverctrlsW) goto exit;
210 if (clientctrls) {
211 clientctrlsW = controlarrayAtoW( clientctrls );
212 if (!clientctrlsW) goto exit;
215 ret = ldap_rename_ext_sW( ld, dnW, newrdnW, newparentW, delete,
216 serverctrlsW, clientctrlsW );
218 exit:
219 strfreeW( dnW );
220 strfreeW( newrdnW );
221 strfreeW( newparentW );
222 controlarrayfreeW( serverctrlsW );
223 controlarrayfreeW( clientctrlsW );
225 #endif
226 return ret;
228 /***********************************************************************
229 * ldap_rename_ext_sW (WLDAP32.@)
231 * Change the DN of a directory entry (synchronous operation).
233 * PARAMS
234 * ld [I] Pointer to an LDAP context.
235 * dn [I] DN of the entry to change.
236 * newrdn [I] New RDN for the entry.
237 * newparent [I] New parent for the entry.
238 * delete [I] Delete old RDN?
239 * serverctrls [I] Array of LDAP server controls.
240 * clientctrls [I] Array of LDAP client controls.
242 * RETURNS
243 * Success: LDAP_SUCCESS
244 * Failure: An LDAP error code.
246 ULONG CDECL ldap_rename_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
247 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
248 PLDAPControlW *clientctrls )
250 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
251 #ifdef HAVE_LDAP
252 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
253 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
255 ret = WLDAP32_LDAP_NO_MEMORY;
257 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_w(dn),
258 debugstr_w(newrdn), debugstr_w(newparent), delete,
259 serverctrls, clientctrls );
261 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
263 if (dn) {
264 dnU = strWtoU( dn );
265 if (!dnU) goto exit;
267 if (newrdn) {
268 newrdnU = strWtoU( newrdn );
269 if (!newrdnU) goto exit;
271 if (newparent) {
272 newparentU = strWtoU( newparent );
273 if (!newparentU) goto exit;
275 if (serverctrls) {
276 serverctrlsU = controlarrayWtoU( serverctrls );
277 if (!serverctrlsU) goto exit;
279 if (clientctrls) {
280 clientctrlsU = controlarrayWtoU( clientctrls );
281 if (!clientctrlsU) goto exit;
284 ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
285 delete, serverctrlsU, clientctrlsU ));
287 exit:
288 strfreeU( dnU );
289 strfreeU( newrdnU );
290 strfreeU( newparentU );
291 controlarrayfreeU( serverctrlsU );
292 controlarrayfreeU( clientctrlsU );
294 #endif
295 return ret;