http.sys: Add support for adding multiple urls to request queues.
[wine.git] / dlls / wldap32 / delete.c
blob41f8bfe3921b019f9dfd082bb2eef10e78e671bf
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 <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "winldap.h"
27 #include "wine/debug.h"
28 #include "winldap_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
32 /***********************************************************************
33 * ldap_deleteA (WLDAP32.@)
35 * See ldap_deleteW.
37 ULONG CDECL ldap_deleteA( LDAP *ld, char *dn )
39 ULONG ret;
40 WCHAR *dnW = NULL;
42 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
44 if (!ld) return ~0u;
45 if (dn && !(dnW = strAtoW( dn ))) return LDAP_NO_MEMORY;
47 ret = ldap_deleteW( ld, dnW );
48 free( dnW );
49 return ret;
52 /***********************************************************************
53 * ldap_deleteW (WLDAP32.@)
55 * Delete an entry from a directory tree (asynchronous operation).
57 * PARAMS
58 * ld [I] Pointer to an LDAP context.
59 * dn [I] DN of the entry to delete.
61 * RETURNS
62 * Success: Message ID of the add operation.
63 * Failure: An LDAP error code.
65 * NOTES
66 * Call ldap_result with the message ID to get the result of
67 * the operation. Cancel the operation by calling ldap_abandon
68 * with the message ID.
70 ULONG CDECL ldap_deleteW( LDAP *ld, WCHAR *dn )
72 ULONG ret, msg;
74 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
76 ret = ldap_delete_extW( ld, dn, NULL, NULL, &msg );
77 if (ret == LDAP_SUCCESS) return msg;
78 return ~0u;
81 /***********************************************************************
82 * ldap_delete_extA (WLDAP32.@)
84 * See ldap_delete_extW.
86 ULONG CDECL ldap_delete_extA( LDAP *ld, char *dn, LDAPControlA **serverctrls, LDAPControlA **clientctrls,
87 ULONG *message )
89 ULONG ret = LDAP_NO_MEMORY;
90 WCHAR *dnW = NULL;
91 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
93 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls, message );
95 if (!ld) return LDAP_PARAM_ERROR;
97 if (dn && !(dnW = strAtoW( dn ))) goto exit;
98 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
99 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
101 ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
103 exit:
104 free( dnW );
105 controlarrayfreeW( serverctrlsW );
106 controlarrayfreeW( clientctrlsW );
107 return ret;
110 /***********************************************************************
111 * ldap_delete_extW (WLDAP32.@)
113 * Delete an entry from a directory tree (asynchronous operation).
115 * PARAMS
116 * ld [I] Pointer to an LDAP context.
117 * dn [I] DN of the entry to delete.
118 * serverctrls [I] Array of LDAP server controls.
119 * clientctrls [I] Array of LDAP client controls.
120 * message [O] Message ID of the delete operation.
122 * RETURNS
123 * Success: LDAP_SUCCESS
124 * Failure: An LDAP error code.
126 * NOTES
127 * Call ldap_result with the message ID to get the result of
128 * the operation. The serverctrls and clientctrls parameters are
129 * optional and should be set to NULL if not used.
131 ULONG CDECL ldap_delete_extW( LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls, LDAPControlW **clientctrls,
132 ULONG *message )
134 ULONG ret = LDAP_NO_MEMORY;
135 char *dnU = NULL;
136 LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
138 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls, message );
140 if (!ld) return LDAP_PARAM_ERROR;
142 if (dn && !(dnU = strWtoU( dn ))) goto exit;
143 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
144 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
145 else
147 struct ldap_delete_ext_params params = { CTX(ld), dnU, serverctrlsU, clientctrlsU, message };
148 ret = map_error( LDAP_CALL( ldap_delete_ext, &params ));
151 exit:
152 free( dnU );
153 controlarrayfreeU( serverctrlsU );
154 controlarrayfreeU( clientctrlsU );
155 return ret;
158 /***********************************************************************
159 * ldap_delete_ext_sA (WLDAP32.@)
161 * See ldap_delete_ext_sW.
163 ULONG CDECL ldap_delete_ext_sA( LDAP *ld, char *dn, LDAPControlA **serverctrls, LDAPControlA **clientctrls )
165 ULONG ret = LDAP_NO_MEMORY;
166 WCHAR *dnW = NULL;
167 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
169 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls );
171 if (!ld) return LDAP_PARAM_ERROR;
173 if (dn && !(dnW = strAtoW( dn ))) goto exit;
174 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
175 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
177 ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
179 exit:
180 free( dnW );
181 controlarrayfreeW( serverctrlsW );
182 controlarrayfreeW( clientctrlsW );
183 return ret;
186 /***********************************************************************
187 * ldap_delete_ext_sW (WLDAP32.@)
189 * Delete an entry from a directory tree (synchronous operation).
191 * PARAMS
192 * ld [I] Pointer to an LDAP context.
193 * dn [I] DN of the entry to delete.
194 * serverctrls [I] Array of LDAP server controls.
195 * clientctrls [I] Array of LDAP client controls.
197 * RETURNS
198 * Success: LDAP_SUCCESS
199 * Failure: An LDAP error code.
201 * NOTES
202 * The serverctrls and clientctrls parameters are optional and
203 * should be set to NULL if not used.
205 ULONG CDECL ldap_delete_ext_sW( LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls, LDAPControlW **clientctrls )
207 ULONG ret = LDAP_NO_MEMORY;
208 char *dnU = NULL;
209 LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
211 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls );
213 if (!ld) return LDAP_PARAM_ERROR;
215 if (dn && !(dnU = strWtoU( dn ))) goto exit;
216 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
217 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
218 else
220 struct ldap_delete_ext_s_params params = { CTX(ld), dnU, serverctrlsU, clientctrlsU };
221 ret = map_error( LDAP_CALL( ldap_delete_ext_s, &params ));
224 exit:
225 free( dnU );
226 controlarrayfreeU( serverctrlsU );
227 controlarrayfreeU( clientctrlsU );
228 return ret;
231 /***********************************************************************
232 * ldap_delete_sA (WLDAP32.@)
234 * See ldap_delete_sW.
236 ULONG CDECL ldap_delete_sA( LDAP *ld, char *dn )
238 ULONG ret;
239 WCHAR *dnW = NULL;
241 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
243 if (!ld) return LDAP_PARAM_ERROR;
244 if (dn && !(dnW = strAtoW( dn ))) return LDAP_NO_MEMORY;
246 ret = ldap_delete_sW( ld, dnW );
247 free( dnW );
248 return ret;
251 /***********************************************************************
252 * ldap_delete_sW (WLDAP32.@)
254 * Delete an entry from a directory tree (synchronous operation).
256 * PARAMS
257 * ld [I] Pointer to an LDAP context.
258 * dn [I] DN of the entry to delete.
260 * RETURNS
261 * Success: LDAP_SUCCESS
262 * Failure: An LDAP error code.
264 ULONG CDECL ldap_delete_sW( LDAP *ld, WCHAR *dn )
266 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
267 return ldap_delete_ext_sW( ld, dn, NULL, NULL );