ReactOS  0.4.14-dev-323-g6fe6a88
modrdn.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_modrdnA (WLDAP32.@)
41  *
42  * See ldap_modrdnW.
43  */
45 {
47 #ifdef HAVE_LDAP
48  WCHAR *dnW = NULL, *newdnW = NULL;
49 
51 
52  TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
53 
54  if (!ld || !newdn) return ~0u;
55 
56  if (dn) {
57  dnW = strAtoW( dn );
58  if (!dnW) goto exit;
59  }
60 
61  newdnW = strAtoW( newdn );
62  if (!newdnW) goto exit;
63 
64  ret = ldap_modrdnW( ld, dnW, newdnW );
65 
66 exit:
67  strfreeW( dnW );
68  strfreeW( newdnW );
69 
70 #endif
71  return ret;
72 }
73 
74 /***********************************************************************
75  * ldap_modrdnW (WLDAP32.@)
76  *
77  * Change the RDN of a directory entry (asynchronous operation).
78  *
79  * PARAMS
80  * ld [I] Pointer to an LDAP context.
81  * dn [I] DN of the entry to change.
82  * newdn [I] New DN for the entry.
83  *
84  * RETURNS
85  * Success: Message ID of the modrdn operation.
86  * Failure: An LDAP error code.
87  *
88  * NOTES
89  * Call ldap_result with the message ID to get the result of
90  * the operation. Cancel the operation by calling ldap_abandon
91  * with the message ID.
92  */
94 {
96 #ifdef HAVE_LDAP
97  char *dnU = NULL, *newdnU = NULL;
98  int msg;
99 
101 
102  TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
103 
104  if (!ld || !newdn) return ~0u;
105 
106  if (dn) {
107  dnU = strWtoU( dn );
108  if (!dnU) goto exit;
109  }
110 
111  newdnU = strWtoU( newdn );
112  if (!newdnU) goto exit;
113 
114  ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
115 
116  if (ret == LDAP_SUCCESS)
117  ret = msg;
118  else
119  ret = ~0u;
120 
121 exit:
122  strfreeU( dnU );
123  strfreeU( newdnU );
124 
125 #endif
126  return ret;
127 }
128 
129 /***********************************************************************
130  * ldap_modrdn2A (WLDAP32.@)
131  *
132  * See ldap_modrdn2W.
133  */
135 {
137 #ifdef HAVE_LDAP
138  WCHAR *dnW = NULL, *newdnW = NULL;
139 
141 
142  TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
143 
144  if (!ld || !newdn) return ~0u;
145 
146  if (dn) {
147  dnW = strAtoW( dn );
148  if (!dnW) goto exit;
149  }
150 
151  newdnW = strAtoW( newdn );
152  if (!newdnW) goto exit;
153 
154  ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
155 
156 exit:
157  strfreeW( dnW );
158  strfreeW( newdnW );
159 
160 #endif
161  return ret;
162 }
163 
164 /***********************************************************************
165  * ldap_modrdn2W (WLDAP32.@)
166  *
167  * Change the RDN of a directory entry (asynchronous operation).
168  *
169  * PARAMS
170  * ld [I] Pointer to an LDAP context.
171  * dn [I] DN of the entry to change.
172  * newdn [I] New DN for the entry.
173  * delete [I] Delete old DN?
174  *
175  * RETURNS
176  * Success: Message ID of the modrdn operation.
177  * Failure: An LDAP error code.
178  *
179  * NOTES
180  * Call ldap_result with the message ID to get the result of
181  * the operation. Cancel the operation by calling ldap_abandon
182  * with the message ID.
183  */
185 {
187 #ifdef HAVE_LDAP
188  char *dnU = NULL, *newdnU = NULL;
189  int msg;
190 
192 
193  TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
194 
195  if (!ld || !newdn) return ~0u;
196 
197  if (dn) {
198  dnU = strWtoU( dn );
199  if (!dnU) goto exit;
200  }
201 
202  newdnU = strWtoU( newdn );
203  if (!newdnU) goto exit;
204 
205  ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
206 
207  if (ret == LDAP_SUCCESS)
208  ret = msg;
209  else
210  ret = ~0u;
211 
212 exit:
213  strfreeU( dnU );
214  strfreeU( newdnU );
215 
216 #endif
217  return ret;
218 }
219 
220 /***********************************************************************
221  * ldap_modrdn2_sA (WLDAP32.@)
222  *
223  * See ldap_modrdn2_sW.
224  */
226 {
228 #ifdef HAVE_LDAP
229  WCHAR *dnW = NULL, *newdnW = NULL;
230 
232 
233  TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
234 
235  if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
236 
237  if (dn) {
238  dnW = strAtoW( dn );
239  if (!dnW) goto exit;
240  }
241 
242  newdnW = strAtoW( newdn );
243  if (!newdnW) goto exit;
244 
245  ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
246 
247 exit:
248  strfreeW( dnW );
249  strfreeW( newdnW );
250 
251 #endif
252  return ret;
253 }
254 
255 /***********************************************************************
256  * ldap_modrdn2_sW (WLDAP32.@)
257  *
258  * Change the RDN of a directory entry (synchronous operation).
259  *
260  * PARAMS
261  * ld [I] Pointer to an LDAP context.
262  * dn [I] DN of the entry to change.
263  * newdn [I] New DN for the entry.
264  * delete [I] Delete old DN?
265  *
266  * RETURNS
267  * Success: LDAP_SUCCESS
268  * Failure: An LDAP error code.
269  */
271 {
273 #ifdef HAVE_LDAP
274  char *dnU = NULL, *newdnU = NULL;
275 
277 
278  TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
279 
280  if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
281 
282  if (dn) {
283  dnU = strWtoU( dn );
284  if (!dnU) goto exit;
285  }
286 
287  newdnU = strWtoU( newdn );
288  if (!newdnU) goto exit;
289 
290  ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL ));
291 
292 exit:
293  strfreeU( dnU );
294  strfreeU( newdnU );
295 
296 #endif
297  return ret;
298 }
299 
300 /***********************************************************************
301  * ldap_modrdn_sA (WLDAP32.@)
302  *
303  * See ldap_modrdn_sW.
304  */
306 {
308 #ifdef HAVE_LDAP
309  WCHAR *dnW = NULL, *newdnW = NULL;
310 
312 
313  TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
314 
315  if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
316 
317  if (dn) {
318  dnW = strAtoW( dn );
319  if (!dnW) goto exit;
320  }
321 
322  newdnW = strAtoW( newdn );
323  if (!newdnW) goto exit;
324 
325  ret = ldap_modrdn_sW( ld, dnW, newdnW );
326 
327 exit:
328  strfreeW( dnW );
329  strfreeW( newdnW );
330 
331 #endif
332  return ret;
333 }
334 
335 /***********************************************************************
336  * ldap_modrdn_sW (WLDAP32.@)
337  *
338  * Change the RDN of a directory entry (synchronous operation).
339  *
340  * PARAMS
341  * ld [I] Pointer to an LDAP context.
342  * dn [I] DN of the entry to change.
343  * newdn [I] New DN for the entry.
344  *
345  * RETURNS
346  * Success: LDAP_SUCCESS
347  * Failure: An LDAP error code.
348  */
350 {
352 #ifdef HAVE_LDAP
353  char *dnU = NULL, *newdnU = NULL;
354 
356 
357  TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
358 
359  if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
360 
361  if (dn) {
362  dnU = strWtoU( dn );
363  if (!dnU) goto exit;
364  }
365 
366  newdnU = strWtoU( newdn );
367  if (!newdnU) goto exit;
368 
369  ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL ));
370 
371 exit:
372  strfreeU( dnU );
373  strfreeU( newdnU );
374 
375 #endif
376  return ret;
377 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
signed char * PCHAR
Definition: retypes.h:7
ULONG CDECL ldap_modrdn_sA(WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn)
Definition: modrdn.c:305
static char * strWtoU(LPCWSTR str)
Definition: wldap32.h:74
#define ldap_rename_s
Definition: winldap.h:699
static void strfreeU(char *str)
Definition: wldap32.h:108
static void strfreeW(LPWSTR str)
Definition: wldap32.h:103
uint16_t * PWCHAR
Definition: typedefs.h:54
ULONG CDECL ldap_modrdn2_sA(WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete)
Definition: modrdn.c:225
int32_t INT
Definition: typedefs.h:56
ULONG CDECL ldap_modrdn2A(WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete)
Definition: modrdn.c:134
ULONG CDECL ldap_modrdn_sW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn)
Definition: modrdn.c:349
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
ULONG CDECL ldap_modrdn2_sW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete)
Definition: modrdn.c:270
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
ULONG CDECL ldap_modrdnA(WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn)
Definition: modrdn.c:44
int ret
static LPWSTR strAtoW(const char *str)
#define CDECL
Definition: compat.h:21
ULONG CDECL ldap_modrdnW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn)
Definition: modrdn.c:93
#define ldap_rename
Definition: winldap.h:698
#define LDAP_SUCCESS
Definition: winldap.h:59
#define msg(x)
Definition: auth_time.c:54
unsigned int ULONG
Definition: retypes.h:1
static UINT map_error(DWORD error)
Definition: service.c:36
void exit(int exitcode)
Definition: _exit.c:33
WINE_DEFAULT_DEBUG_CHANNEL(wldap32)
ULONG CDECL ldap_modrdn2W(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete)
Definition: modrdn.c:184