wbemdisp: Implement GetObjectText_().
[wine/zf.git] / dlls / wldap32 / delete.c
blob95d636e4874298a44b0b975144812b8207e8b70d
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 #ifdef HAVE_LDAP
38 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
39 #endif
41 /***********************************************************************
42 * ldap_deleteA (WLDAP32.@)
44 * See ldap_deleteW.
46 ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
48 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
49 #ifdef HAVE_LDAP
50 WCHAR *dnW = NULL;
52 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
54 if (!ld) return ~0u;
56 if (dn) {
57 dnW = strAtoW( dn );
58 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
61 ret = ldap_deleteW( ld, dnW );
62 strfreeW( dnW );
64 #endif
65 return ret;
68 /***********************************************************************
69 * ldap_deleteW (WLDAP32.@)
71 * Delete an entry from a directory tree (asynchronous operation).
73 * PARAMS
74 * ld [I] Pointer to an LDAP context.
75 * dn [I] DN of the entry to delete.
77 * RETURNS
78 * Success: Message ID of the add operation.
79 * Failure: An LDAP error code.
81 * NOTES
82 * Call ldap_result with the message ID to get the result of
83 * the operation. Cancel the operation by calling ldap_abandon
84 * with the message ID.
86 ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
88 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
89 #ifdef HAVE_LDAP
90 char *dnU = NULL;
91 int msg;
93 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
95 if (!ld) return ~0u;
97 if (dn) {
98 dnU = strWtoU( dn );
99 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
102 ret = ldap_delete_ext( ld->ld, dn ? dnU : "", NULL, NULL, &msg );
104 if (ret == LDAP_SUCCESS)
105 ret = msg;
106 else
107 ret = ~0u;
109 strfreeU( dnU );
111 #endif
112 return ret;
115 /***********************************************************************
116 * ldap_delete_extA (WLDAP32.@)
118 * See ldap_delete_extW.
120 ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
121 PLDAPControlA *clientctrls, ULONG *message )
123 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
124 #ifdef HAVE_LDAP
125 WCHAR *dnW = NULL;
126 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
128 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
129 clientctrls, message );
131 ret = WLDAP32_LDAP_NO_MEMORY;
133 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
135 if (dn) {
136 dnW = strAtoW( dn );
137 if (!dnW) goto exit;
139 if (serverctrls) {
140 serverctrlsW = controlarrayAtoW( serverctrls );
141 if (!serverctrlsW) goto exit;
143 if (clientctrls) {
144 clientctrlsW = controlarrayAtoW( clientctrls );
145 if (!clientctrlsW) goto exit;
148 ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
150 exit:
151 strfreeW( dnW );
152 controlarrayfreeW( serverctrlsW );
153 controlarrayfreeW( clientctrlsW );
155 #endif
156 return ret;
159 /***********************************************************************
160 * ldap_delete_extW (WLDAP32.@)
162 * Delete an entry from a directory tree (asynchronous operation).
164 * PARAMS
165 * ld [I] Pointer to an LDAP context.
166 * dn [I] DN of the entry to delete.
167 * serverctrls [I] Array of LDAP server controls.
168 * clientctrls [I] Array of LDAP client controls.
169 * message [O] Message ID of the delete operation.
171 * RETURNS
172 * Success: LDAP_SUCCESS
173 * Failure: An LDAP error code.
175 * NOTES
176 * Call ldap_result with the message ID to get the result of
177 * the operation. The serverctrls and clientctrls parameters are
178 * optional and should be set to NULL if not used.
180 ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
181 PLDAPControlW *clientctrls, ULONG *message )
183 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
184 #ifdef HAVE_LDAP
185 char *dnU = NULL;
186 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
187 int dummy;
189 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
190 clientctrls, message );
192 ret = WLDAP32_LDAP_NO_MEMORY;
194 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
196 if (dn) {
197 dnU = strWtoU( dn );
198 if (!dnU) goto exit;
200 if (serverctrls) {
201 serverctrlsU = controlarrayWtoU( serverctrls );
202 if (!serverctrlsU) goto exit;
204 if (clientctrls) {
205 clientctrlsU = controlarrayWtoU( clientctrls );
206 if (!clientctrlsU) goto exit;
209 ret = map_error( ldap_delete_ext( ld->ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
210 message ? (int *)message : &dummy ));
212 exit:
213 strfreeU( dnU );
214 controlarrayfreeU( serverctrlsU );
215 controlarrayfreeU( clientctrlsU );
217 #endif
218 return ret;
221 /***********************************************************************
222 * ldap_delete_ext_sA (WLDAP32.@)
224 * See ldap_delete_ext_sW.
226 ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
227 PLDAPControlA *clientctrls )
229 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
230 #ifdef HAVE_LDAP
231 WCHAR *dnW = NULL;
232 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
234 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
235 clientctrls );
237 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
239 if (dn) {
240 dnW = strAtoW( dn );
241 if (!dnW) goto exit;
243 if (serverctrls) {
244 serverctrlsW = controlarrayAtoW( serverctrls );
245 if (!serverctrlsW) goto exit;
247 if (clientctrls) {
248 clientctrlsW = controlarrayAtoW( clientctrls );
249 if (!clientctrlsW) goto exit;
252 ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
254 exit:
255 strfreeW( dnW );
256 controlarrayfreeW( serverctrlsW );
257 controlarrayfreeW( clientctrlsW );
259 #endif
260 return ret;
263 /***********************************************************************
264 * ldap_delete_ext_sW (WLDAP32.@)
266 * Delete an entry from a directory tree (synchronous operation).
268 * PARAMS
269 * ld [I] Pointer to an LDAP context.
270 * dn [I] DN of the entry to delete.
271 * serverctrls [I] Array of LDAP server controls.
272 * clientctrls [I] Array of LDAP client controls.
274 * RETURNS
275 * Success: LDAP_SUCCESS
276 * Failure: An LDAP error code.
278 * NOTES
279 * The serverctrls and clientctrls parameters are optional and
280 * should be set to NULL if not used.
282 ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
283 PLDAPControlW *clientctrls )
285 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
286 #ifdef HAVE_LDAP
287 char *dnU = NULL;
288 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
290 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
291 clientctrls );
293 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
295 if (dn) {
296 dnU = strWtoU( dn );
297 if (!dnU) goto exit;
299 if (serverctrls) {
300 serverctrlsU = controlarrayWtoU( serverctrls );
301 if (!serverctrlsU) goto exit;
303 if (clientctrls) {
304 clientctrlsU = controlarrayWtoU( clientctrls );
305 if (!clientctrlsU) goto exit;
308 ret = map_error( ldap_delete_ext_s( ld->ld, dn ? dnU : "", serverctrlsU, clientctrlsU ));
310 exit:
311 strfreeU( dnU );
312 controlarrayfreeU( serverctrlsU );
313 controlarrayfreeU( clientctrlsU );
315 #endif
316 return ret;
319 /***********************************************************************
320 * ldap_delete_sA (WLDAP32.@)
322 * See ldap_delete_sW.
324 ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
326 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
327 #ifdef HAVE_LDAP
328 WCHAR *dnW = NULL;
330 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
332 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
334 if (dn) {
335 dnW = strAtoW( dn );
336 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
339 ret = ldap_delete_sW( ld, dnW );
340 strfreeW( dnW );
342 #endif
343 return ret;
346 /***********************************************************************
347 * ldap_delete_sW (WLDAP32.@)
349 * Delete an entry from a directory tree (synchronous operation).
351 * PARAMS
352 * ld [I] Pointer to an LDAP context.
353 * dn [I] DN of the entry to delete.
355 * RETURNS
356 * Success: LDAP_SUCCESS
357 * Failure: An LDAP error code.
359 ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
361 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
362 #ifdef HAVE_LDAP
363 char *dnU = NULL;
365 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
367 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
369 if (dn) {
370 dnU = strWtoU( dn );
371 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
374 ret = map_error( ldap_delete_ext_s( ld->ld, dn ? dnU : "", NULL, NULL ));
375 strfreeU( dnU );
377 #endif
378 return ret;