ReactOS 0.4.15-dev-8058-ga7cbb60
rename.c
Go to the documentation of this file.
1/*
2 * WLDAP32 - LDAP support for Wine
3 *
4 * Copyright 2005 Hans Leidekker
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "config.h"
22#include "wine/port.h"
23
24#include <stdarg.h>
25#ifdef HAVE_LDAP_H
26#include <ldap.h>
27#endif
28
29#include "windef.h"
30#include "winbase.h"
31#include "winnls.h"
32
33#include "winldap_private.h"
34#include "wldap32.h"
35#include "wine/debug.h"
36
38
39/***********************************************************************
40 * ldap_rename_extA (WLDAP32.@)
41 *
42 * See ldap_rename_extW.
43 */
45 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
46 PLDAPControlA *clientctrls, ULONG *message )
47{
49#ifdef HAVE_LDAP
50 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
51 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
52
54
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 );
58
59 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
60
61 if (dn) {
62 dnW = strAtoW( dn );
63 if (!dnW) goto exit;
64 }
65 if (newrdn) {
66 newrdnW = strAtoW( newrdn );
67 if (!newrdnW) goto exit;
68 }
69 if (newparent) {
70 newparentW = strAtoW( newparent );
71 if (!newparentW) goto exit;
72 }
73 if (serverctrls) {
74 serverctrlsW = controlarrayAtoW( serverctrls );
75 if (!serverctrlsW) goto exit;
76 }
77 if (clientctrls) {
78 clientctrlsW = controlarrayAtoW( clientctrls );
79 if (!clientctrlsW) goto exit;
80 }
81
82 ret = ldap_rename_extW( ld, dnW, newrdnW, newparentW, delete,
83 serverctrlsW, clientctrlsW, message );
84
85exit:
86 strfreeW( dnW );
87 strfreeW( newrdnW );
88 strfreeW( newparentW );
89 controlarrayfreeW( serverctrlsW );
90 controlarrayfreeW( clientctrlsW );
91
92#endif
93 return ret;
94}
95
96/***********************************************************************
97 * ldap_rename_extW (WLDAP32.@)
98 *
99 * Change the DN of a directory entry (asynchronous operation).
100 *
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.
110 *
111 * RETURNS
112 * Success: LDAP_SUCCESS
113 * Failure: An LDAP error code.
114 *
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.
119 */
121 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
122 PLDAPControlW *clientctrls, ULONG *message )
123{
125#ifdef HAVE_LDAP
126 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
127 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
128
130
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 );
134
135 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
136
137 if (dn) {
138 dnU = strWtoU( dn );
139 if (!dnU) goto exit;
140 }
141 if (newrdn) {
142 newrdnU = strWtoU( newrdn );
143 if (!newrdnU) goto exit;
144 }
145 if (newparent) {
146 newparentU = strWtoU( newparent );
147 if (!newparentU) goto exit;
148 }
149 if (serverctrls) {
150 serverctrlsU = controlarrayWtoU( serverctrls );
151 if (!serverctrlsU) goto exit;
152 }
153 if (clientctrls) {
154 clientctrlsU = controlarrayWtoU( clientctrls );
155 if (!clientctrlsU) goto exit;
156 }
157
158 ret = map_error( ldap_rename( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
159 delete, serverctrlsU, clientctrlsU, (int *)message ));
160
161exit:
162 strfreeU( dnU );
163 strfreeU( newrdnU );
164 strfreeU( newparentU );
165 controlarrayfreeU( serverctrlsU );
166 controlarrayfreeU( clientctrlsU );
167
168#endif
169 return ret;
170}
171
172/***********************************************************************
173 * ldap_rename_ext_sA (WLDAP32.@)
174 *
175 * See ldap_rename_ext_sW.
176 */
178 PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
179 PLDAPControlA *clientctrls )
180{
182#ifdef HAVE_LDAP
183 WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
184 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
185
187
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 );
191
192 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
193
194 if (dn) {
195 dnW = strAtoW( dn );
196 if (!dnW) goto exit;
197 }
198 if (newrdn) {
199 newrdnW = strAtoW( newrdn );
200 if (!newrdnW) goto exit;
201 }
202 if (newparent) {
203 newparentW = strAtoW( newparent );
204 if (!newparentW) goto exit;
205 }
206 if (serverctrls) {
207 serverctrlsW = controlarrayAtoW( serverctrls );
208 if (!serverctrlsW) goto exit;
209 }
210 if (clientctrls) {
211 clientctrlsW = controlarrayAtoW( clientctrls );
212 if (!clientctrlsW) goto exit;
213 }
214
215 ret = ldap_rename_ext_sW( ld, dnW, newrdnW, newparentW, delete,
216 serverctrlsW, clientctrlsW );
217
218exit:
219 strfreeW( dnW );
220 strfreeW( newrdnW );
221 strfreeW( newparentW );
222 controlarrayfreeW( serverctrlsW );
223 controlarrayfreeW( clientctrlsW );
224
225#endif
226 return ret;
227}
228/***********************************************************************
229 * ldap_rename_ext_sW (WLDAP32.@)
230 *
231 * Change the DN of a directory entry (synchronous operation).
232 *
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.
241 *
242 * RETURNS
243 * Success: LDAP_SUCCESS
244 * Failure: An LDAP error code.
245 */
247 PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
248 PLDAPControlW *clientctrls )
249{
251#ifdef HAVE_LDAP
252 char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
253 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
254
256
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 );
260
261 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
262
263 if (dn) {
264 dnU = strWtoU( dn );
265 if (!dnU) goto exit;
266 }
267 if (newrdn) {
268 newrdnU = strWtoU( newrdn );
269 if (!newrdnU) goto exit;
270 }
271 if (newparent) {
272 newparentU = strWtoU( newparent );
273 if (!newparentU) goto exit;
274 }
275 if (serverctrls) {
276 serverctrlsU = controlarrayWtoU( serverctrls );
277 if (!serverctrlsU) goto exit;
278 }
279 if (clientctrls) {
280 clientctrlsU = controlarrayWtoU( clientctrls );
281 if (!clientctrlsU) goto exit;
282 }
283
284 ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
285 delete, serverctrlsU, clientctrlsU ));
286
287exit:
288 strfreeU( dnU );
289 strfreeU( newrdnU );
290 strfreeU( newparentU );
291 controlarrayfreeU( serverctrlsU );
292 controlarrayfreeU( clientctrlsU );
293
294#endif
295 return ret;
296}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
static UINT map_error(DWORD error)
Definition: service.c:35
static LPWSTR strAtoW(const char *str)
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
ULONG CDECL ldap_rename_ext_sA(WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn, PCHAR newparent, INT delete, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls)
Definition: rename.c:177
ULONG CDECL ldap_rename_extW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn, PWCHAR newparent, INT delete, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message)
Definition: rename.c:120
ULONG CDECL ldap_rename_ext_sW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn, PWCHAR newparent, INT delete, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls)
Definition: rename.c:246
ULONG CDECL ldap_rename_extA(WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn, PCHAR newparent, INT delete, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message)
Definition: rename.c:44
#define exit(n)
Definition: config.h:202
#define TRACE(s)
Definition: solgame.cpp:4
Definition: tftpd.h:60
int32_t INT
Definition: typedefs.h:58
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
int ret
#define LDAPControl
Definition: winldap.h:620
#define ldap_rename_s
Definition: winldap.h:699
#define ldap_rename
Definition: winldap.h:698
@ WLDAP32_LDAP_PARAM_ERROR
@ WLDAP32_LDAP_NOT_SUPPORTED
@ WLDAP32_LDAP_NO_MEMORY
static void strfreeU(char *str)
Definition: wldap32.h:108
static void strfreeW(LPWSTR str)
Definition: wldap32.h:103
static char * strWtoU(LPCWSTR str)
Definition: wldap32.h:74
__wchar_t WCHAR
Definition: xmlstorage.h:180