ReactOS 0.4.16-dev-88-ga65b6ae
delete.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_deleteA (WLDAP32.@)
41 *
42 * See ldap_deleteW.
43 */
45{
47#ifdef HAVE_LDAP
48 WCHAR *dnW = NULL;
49
50 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
51
52 if (!ld) return ~0u;
53
54 if (dn) {
55 dnW = strAtoW( dn );
56 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
57 }
58
59 ret = ldap_deleteW( ld, dnW );
60 strfreeW( dnW );
61
62#endif
63 return ret;
64}
65
66/***********************************************************************
67 * ldap_deleteW (WLDAP32.@)
68 *
69 * Delete an entry from a directory tree (asynchronous operation).
70 *
71 * PARAMS
72 * ld [I] Pointer to an LDAP context.
73 * dn [I] DN of the entry to delete.
74 *
75 * RETURNS
76 * Success: Message ID of the add operation.
77 * Failure: An LDAP error code.
78 *
79 * NOTES
80 * Call ldap_result with the message ID to get the result of
81 * the operation. Cancel the operation by calling ldap_abandon
82 * with the message ID.
83 */
85{
87#ifdef HAVE_LDAP
88 char *dnU = NULL;
89 int msg;
90
91 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
92
93 if (!ld) return ~0u;
94
95 if (dn) {
96 dnU = strWtoU( dn );
97 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
98 }
99
100 ret = ldap_delete_ext( ld, dn ? dnU : "", NULL, NULL, &msg );
101
102 if (ret == LDAP_SUCCESS)
103 ret = msg;
104 else
105 ret = ~0u;
106
107 strfreeU( dnU );
108
109#endif
110 return ret;
111}
112
113/***********************************************************************
114 * ldap_delete_extA (WLDAP32.@)
115 *
116 * See ldap_delete_extW.
117 */
119 PLDAPControlA *clientctrls, ULONG *message )
120{
122#ifdef HAVE_LDAP
123 WCHAR *dnW = NULL;
124 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
125
126 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
127 clientctrls, message );
128
130
131 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
132
133 if (dn) {
134 dnW = strAtoW( dn );
135 if (!dnW) goto exit;
136 }
137 if (serverctrls) {
138 serverctrlsW = controlarrayAtoW( serverctrls );
139 if (!serverctrlsW) goto exit;
140 }
141 if (clientctrls) {
142 clientctrlsW = controlarrayAtoW( clientctrls );
143 if (!clientctrlsW) goto exit;
144 }
145
146 ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
147
148exit:
149 strfreeW( dnW );
150 controlarrayfreeW( serverctrlsW );
151 controlarrayfreeW( clientctrlsW );
152
153#endif
154 return ret;
155}
156
157/***********************************************************************
158 * ldap_delete_extW (WLDAP32.@)
159 *
160 * Delete an entry from a directory tree (asynchronous operation).
161 *
162 * PARAMS
163 * ld [I] Pointer to an LDAP context.
164 * dn [I] DN of the entry to delete.
165 * serverctrls [I] Array of LDAP server controls.
166 * clientctrls [I] Array of LDAP client controls.
167 * message [O] Message ID of the delete operation.
168 *
169 * RETURNS
170 * Success: LDAP_SUCCESS
171 * Failure: An LDAP error code.
172 *
173 * NOTES
174 * Call ldap_result with the message ID to get the result of
175 * the operation. The serverctrls and clientctrls parameters are
176 * optional and should be set to NULL if not used.
177 */
179 PLDAPControlW *clientctrls, ULONG *message )
180{
182#ifdef HAVE_LDAP
183 char *dnU = NULL;
184 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
185 int dummy;
186
187 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
188 clientctrls, message );
189
191
192 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
193
194 if (dn) {
195 dnU = strWtoU( dn );
196 if (!dnU) goto exit;
197 }
198 if (serverctrls) {
199 serverctrlsU = controlarrayWtoU( serverctrls );
200 if (!serverctrlsU) goto exit;
201 }
202 if (clientctrls) {
203 clientctrlsU = controlarrayWtoU( clientctrls );
204 if (!clientctrlsU) goto exit;
205 }
206
207 ret = map_error( ldap_delete_ext( ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
208 message ? (int *)message : &dummy ));
209
210exit:
211 strfreeU( dnU );
212 controlarrayfreeU( serverctrlsU );
213 controlarrayfreeU( clientctrlsU );
214
215#endif
216 return ret;
217}
218
219/***********************************************************************
220 * ldap_delete_ext_sA (WLDAP32.@)
221 *
222 * See ldap_delete_ext_sW.
223 */
225 PLDAPControlA *clientctrls )
226{
228#ifdef HAVE_LDAP
229 WCHAR *dnW = NULL;
230 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
231
232 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
233 clientctrls );
234
235 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
236
237 if (dn) {
238 dnW = strAtoW( dn );
239 if (!dnW) goto exit;
240 }
241 if (serverctrls) {
242 serverctrlsW = controlarrayAtoW( serverctrls );
243 if (!serverctrlsW) goto exit;
244 }
245 if (clientctrls) {
246 clientctrlsW = controlarrayAtoW( clientctrls );
247 if (!clientctrlsW) goto exit;
248 }
249
250 ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
251
252exit:
253 strfreeW( dnW );
254 controlarrayfreeW( serverctrlsW );
255 controlarrayfreeW( clientctrlsW );
256
257#endif
258 return ret;
259}
260
261/***********************************************************************
262 * ldap_delete_ext_sW (WLDAP32.@)
263 *
264 * Delete an entry from a directory tree (synchronous operation).
265 *
266 * PARAMS
267 * ld [I] Pointer to an LDAP context.
268 * dn [I] DN of the entry to delete.
269 * serverctrls [I] Array of LDAP server controls.
270 * clientctrls [I] Array of LDAP client controls.
271 *
272 * RETURNS
273 * Success: LDAP_SUCCESS
274 * Failure: An LDAP error code.
275 *
276 * NOTES
277 * The serverctrls and clientctrls parameters are optional and
278 * should be set to NULL if not used.
279 */
281 PLDAPControlW *clientctrls )
282{
284#ifdef HAVE_LDAP
285 char *dnU = NULL;
286 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
287
288 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
289 clientctrls );
290
291 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
292
293 if (dn) {
294 dnU = strWtoU( dn );
295 if (!dnU) goto exit;
296 }
297 if (serverctrls) {
298 serverctrlsU = controlarrayWtoU( serverctrls );
299 if (!serverctrlsU) goto exit;
300 }
301 if (clientctrls) {
302 clientctrlsU = controlarrayWtoU( clientctrls );
303 if (!clientctrlsU) goto exit;
304 }
305
306 ret = map_error( ldap_delete_ext_s( ld, dn ? dnU : "", serverctrlsU, clientctrlsU ));
307
308exit:
309 strfreeU( dnU );
310 controlarrayfreeU( serverctrlsU );
311 controlarrayfreeU( clientctrlsU );
312
313#endif
314 return ret;
315}
316
317/***********************************************************************
318 * ldap_delete_sA (WLDAP32.@)
319 *
320 * See ldap_delete_sW.
321 */
323{
325#ifdef HAVE_LDAP
326 WCHAR *dnW = NULL;
327
328 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
329
330 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
331
332 if (dn) {
333 dnW = strAtoW( dn );
334 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
335 }
336
337 ret = ldap_delete_sW( ld, dnW );
338 strfreeW( dnW );
339
340#endif
341 return ret;
342}
343
344/***********************************************************************
345 * ldap_delete_sW (WLDAP32.@)
346 *
347 * Delete an entry from a directory tree (synchronous operation).
348 *
349 * PARAMS
350 * ld [I] Pointer to an LDAP context.
351 * dn [I] DN of the entry to delete.
352 *
353 * RETURNS
354 * Success: LDAP_SUCCESS
355 * Failure: An LDAP error code.
356 */
358{
360#ifdef HAVE_LDAP
361 char *dnU = NULL;
362
363 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
364
365 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
366
367 if (dn) {
368 dnU = strWtoU( dn );
369 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
370 }
371
372 ret = map_error( ldap_delete_ext_s( ld, dn ? dnU : "", NULL, NULL ));
373 strfreeU( dnU );
374
375#endif
376 return ret;
377}
#define msg(x)
Definition: auth_time.c:54
#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
ULONG CDECL ldap_deleteA(WLDAP32_LDAP *ld, PCHAR dn)
Definition: delete.c:44
ULONG CDECL ldap_delete_ext_sA(WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls)
Definition: delete.c:224
ULONG CDECL ldap_delete_sA(WLDAP32_LDAP *ld, PCHAR dn)
Definition: delete.c:322
ULONG CDECL ldap_delete_ext_sW(WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls)
Definition: delete.c:280
ULONG CDECL ldap_delete_extA(WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message)
Definition: delete.c:118
ULONG CDECL ldap_delete_sW(WLDAP32_LDAP *ld, PWCHAR dn)
Definition: delete.c:357
ULONG CDECL ldap_deleteW(WLDAP32_LDAP *ld, PWCHAR dn)
Definition: delete.c:84
ULONG CDECL ldap_delete_extW(WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message)
Definition: delete.c:178
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
static LPWSTR strAtoW(const char *str)
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define exit(n)
Definition: config.h:202
#define TRACE(s)
Definition: solgame.cpp:4
Definition: tftpd.h:60
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_delete_ext_s
Definition: winldap.h:654
#define ldap_delete_ext
Definition: winldap.h:652
#define LDAP_SUCCESS
Definition: winldap.h:59
@ 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