d3d: Don't crash when SetRenderTarget() is called with a NULL pSurface.
[wine/hacks.git] / dlls / wldap32 / modrdn.c
blob2c005498b45383da4ca0a8de27477989ee25e475
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_modrdnA (WLDAP32.@)
46 * See ldap_modrdnW.
48 ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
50 ULONG ret = LDAP_NOT_SUPPORTED;
51 #ifdef HAVE_LDAP
52 WCHAR *dnW = NULL, *newdnW = NULL;
54 ret = WLDAP32_LDAP_NO_MEMORY;
56 TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
58 if (!ld || !newdn) return ~0UL;
60 if (dn) {
61 dnW = strAtoW( dn );
62 if (!dnW) goto exit;
65 newdnW = strAtoW( newdn );
66 if (!newdnW) goto exit;
68 ret = ldap_modrdnW( ld, dnW, newdnW );
70 exit:
71 strfreeW( dnW );
72 strfreeW( newdnW );
74 #endif
75 return ret;
78 /***********************************************************************
79 * ldap_modrdnW (WLDAP32.@)
81 * Change the RDN of a directory entry (asynchronous operation).
83 * PARAMS
84 * ld [I] Pointer to an LDAP context.
85 * dn [I] DN of the entry to change.
86 * newdn [I] New DN for the entry.
88 * RETURNS
89 * Success: Message ID of the modrdn operation.
90 * Failure: An LDAP error code.
92 * NOTES
93 * Call ldap_result with the message ID to get the result of
94 * the operation. Cancel the operation by calling ldap_abandon
95 * with the message ID.
97 ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
99 ULONG ret = LDAP_NOT_SUPPORTED;
100 #ifdef HAVE_LDAP
101 char *dnU = NULL, *newdnU = NULL;
102 int msg;
104 ret = WLDAP32_LDAP_NO_MEMORY;
106 TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
108 if (!ld || !newdn) return ~0UL;
110 if (dn) {
111 dnU = strWtoU( dn );
112 if (!dnU) goto exit;
115 newdnU = strWtoU( newdn );
116 if (!newdnU) goto exit;
118 ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
120 if (ret == LDAP_SUCCESS)
121 ret = msg;
122 else
123 ret = ~0UL;
125 exit:
126 strfreeU( dnU );
127 strfreeU( newdnU );
129 #endif
130 return ret;
133 /***********************************************************************
134 * ldap_modrdn2A (WLDAP32.@)
136 * See ldap_modrdn2W.
138 ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
140 ULONG ret = LDAP_NOT_SUPPORTED;
141 #ifdef HAVE_LDAP
142 WCHAR *dnW = NULL, *newdnW = NULL;
144 ret = WLDAP32_LDAP_NO_MEMORY;
146 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
148 if (!ld || !newdn) return ~0UL;
150 if (dn) {
151 dnW = strAtoW( dn );
152 if (!dnW) goto exit;
155 newdnW = strAtoW( newdn );
156 if (!newdnW) goto exit;
158 ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
160 exit:
161 strfreeW( dnW );
162 strfreeW( newdnW );
164 #endif
165 return ret;
168 /***********************************************************************
169 * ldap_modrdn2W (WLDAP32.@)
171 * Change the RDN of a directory entry (asynchronous operation).
173 * PARAMS
174 * ld [I] Pointer to an LDAP context.
175 * dn [I] DN of the entry to change.
176 * newdn [I] New DN for the entry.
177 * delete [I] Delete old DN?
179 * RETURNS
180 * Success: Message ID of the modrdn operation.
181 * Failure: An LDAP error code.
183 * NOTES
184 * Call ldap_result with the message ID to get the result of
185 * the operation. Cancel the operation by calling ldap_abandon
186 * with the message ID.
188 ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
190 ULONG ret = LDAP_NOT_SUPPORTED;
191 #ifdef HAVE_LDAP
192 char *dnU = NULL, *newdnU = NULL;
193 int msg;
195 ret = WLDAP32_LDAP_NO_MEMORY;
197 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
199 if (!ld || !newdn) return ~0UL;
201 if (dn) {
202 dnU = strWtoU( dn );
203 if (!dnU) goto exit;
206 newdnU = strWtoU( newdn );
207 if (!newdnU) goto exit;
209 ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
211 if (ret == LDAP_SUCCESS)
212 ret = msg;
213 else
214 ret = ~0UL;
216 exit:
217 strfreeU( dnU );
218 strfreeU( newdnU );
220 #endif
221 return ret;
224 /***********************************************************************
225 * ldap_modrdn2_sA (WLDAP32.@)
227 * See ldap_modrdn2_sW.
229 ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
231 ULONG ret = LDAP_NOT_SUPPORTED;
232 #ifdef HAVE_LDAP
233 WCHAR *dnW = NULL, *newdnW = NULL;
235 ret = WLDAP32_LDAP_NO_MEMORY;
237 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
239 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
241 if (dn) {
242 dnW = strAtoW( dn );
243 if (!dnW) goto exit;
246 newdnW = strAtoW( newdn );
247 if (!newdnW) goto exit;
249 ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
251 exit:
252 strfreeW( dnW );
253 strfreeW( newdnW );
255 #endif
256 return ret;
259 /***********************************************************************
260 * ldap_modrdn2_sW (WLDAP32.@)
262 * Change the RDN of a directory entry (synchronous operation).
264 * PARAMS
265 * ld [I] Pointer to an LDAP context.
266 * dn [I] DN of the entry to change.
267 * newdn [I] New DN for the entry.
268 * delete [I] Delete old DN?
270 * RETURNS
271 * Success: LDAP_SUCCESS
272 * Failure: An LDAP error code.
274 ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
276 ULONG ret = LDAP_NOT_SUPPORTED;
277 #ifdef HAVE_LDAP
278 char *dnU = NULL, *newdnU = NULL;
280 ret = WLDAP32_LDAP_NO_MEMORY;
282 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
284 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
286 if (dn) {
287 dnU = strWtoU( dn );
288 if (!dnU) goto exit;
291 newdnU = strWtoU( newdn );
292 if (!newdnU) goto exit;
294 ret = ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL );
296 exit:
297 strfreeU( dnU );
298 strfreeU( newdnU );
300 #endif
301 return ret;
304 /***********************************************************************
305 * ldap_modrdn_sA (WLDAP32.@)
307 * See ldap_modrdn_sW.
309 ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
311 ULONG ret = LDAP_NOT_SUPPORTED;
312 #ifdef HAVE_LDAP
313 WCHAR *dnW = NULL, *newdnW = NULL;
315 ret = WLDAP32_LDAP_NO_MEMORY;
317 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
319 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
321 if (dn) {
322 dnW = strAtoW( dn );
323 if (!dnW) goto exit;
326 newdnW = strAtoW( newdn );
327 if (!newdnW) goto exit;
329 ret = ldap_modrdn_sW( ld, dnW, newdnW );
331 exit:
332 strfreeW( dnW );
333 strfreeW( newdnW );
335 #endif
336 return ret;
339 /***********************************************************************
340 * ldap_modrdn_sW (WLDAP32.@)
342 * Change the RDN of a directory entry (synchronous operation).
344 * PARAMS
345 * ld [I] Pointer to an LDAP context.
346 * dn [I] DN of the entry to change.
347 * newdn [I] New DN for the entry.
349 * RETURNS
350 * Success: LDAP_SUCCESS
351 * Failure: An LDAP error code.
353 ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
355 ULONG ret = LDAP_NOT_SUPPORTED;
356 #ifdef HAVE_LDAP
357 char *dnU = NULL, *newdnU = NULL;
359 ret = WLDAP32_LDAP_NO_MEMORY;
361 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
363 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
365 if (dn) {
366 dnU = strWtoU( dn );
367 if (!dnU) goto exit;
370 newdnU = strWtoU( newdn );
371 if (!newdnU) goto exit;
373 ret = ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL );
375 exit:
376 strfreeU( dnU );
377 strfreeU( newdnU );
379 #endif
380 return ret;