Added CSIDL_MYVIDEO|MYPICTURES|MYMUSIC to _SHRegisterUserShellFolders.
[wine] / dlls / wldap32 / delete.c
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "wine/port.h"
24 #include "wine/debug.h"
25
26 #include <stdarg.h>
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
31
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_NOT_SUPPORTED  0x5c
36 #endif
37
38 #include "winldap_private.h"
39 #include "wldap32.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
42
43 ULONG ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
44 {
45     ULONG ret = LDAP_NOT_SUPPORTED;
46 #ifdef HAVE_LDAP
47     WCHAR *dnW = NULL;
48
49     TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
50
51     if (!ld) return ~0UL;
52
53     if (dn) {
54         dnW = strAtoW( dn );
55         if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
56     }
57
58     ret = ldap_deleteW( ld, dnW );
59     strfreeW( dnW );
60
61 #endif
62     return ret;
63 }
64
65 ULONG ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
66 {
67     ULONG ret = LDAP_NOT_SUPPORTED;
68 #ifdef HAVE_LDAP
69     char *dnU = NULL;
70     int msg;
71
72     TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
73
74     if (!ld) return ~0UL;
75
76     if (dn) {
77         dnU = strWtoU( dn );
78         if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
79     }
80
81     ret = ldap_delete_ext( ld, dn ? dnU : "", NULL, NULL, &msg );
82
83     if (ret == LDAP_SUCCESS)
84         ret = msg;
85     else
86         ret = ~0UL;
87
88     strfreeU( dnU );
89
90 #endif
91     return ret;
92 }
93
94 ULONG ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
95     PLDAPControlA *clientctrls, ULONG *message )
96 {
97     ULONG ret = LDAP_NOT_SUPPORTED;
98 #ifdef HAVE_LDAP
99     WCHAR *dnW = NULL;
100     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
101
102     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
103            clientctrls, message );
104
105     ret = WLDAP32_LDAP_NO_MEMORY;
106
107     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
108
109     if (dn) {
110         dnW = strAtoW( dn );
111         if (!dnW) goto exit;
112     }
113     if (serverctrls) {
114         serverctrlsW = controlarrayAtoW( serverctrls );
115         if (!serverctrlsW) goto exit;
116     }
117     if (clientctrls) {
118         clientctrlsW = controlarrayAtoW( clientctrls );
119         if (!clientctrlsW) goto exit;
120     }
121
122     ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
123
124 exit:
125     strfreeW( dnW );
126     controlarrayfreeW( serverctrlsW );
127     controlarrayfreeW( clientctrlsW );
128
129 #endif
130     return ret;
131 }
132
133 ULONG ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
134     PLDAPControlW *clientctrls, ULONG *message )
135 {
136     ULONG ret = LDAP_NOT_SUPPORTED;
137 #ifdef HAVE_LDAP
138     char *dnU = NULL;
139     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
140     int dummy;
141
142     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
143            clientctrls, message );
144
145     ret = WLDAP32_LDAP_NO_MEMORY;
146
147     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
148
149     if (dn) {
150         dnU = strWtoU( dn );
151         if (!dnU) goto exit;
152     }
153     if (serverctrls) {
154         serverctrlsU = controlarrayWtoU( serverctrls );
155         if (!serverctrlsU) goto exit;
156     }
157     if (clientctrls) {
158         clientctrlsU = controlarrayWtoU( clientctrls );
159         if (!clientctrlsU) goto exit;
160     }
161
162     ret = ldap_delete_ext( ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
163                            message ? (int *)message : &dummy );
164
165 exit:
166     strfreeU( dnU );
167     controlarrayfreeU( serverctrlsU );
168     controlarrayfreeU( clientctrlsU );
169
170 #endif
171     return ret;
172 }
173
174 ULONG ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
175     PLDAPControlA *clientctrls )
176 {
177     ULONG ret = LDAP_NOT_SUPPORTED;
178 #ifdef HAVE_LDAP
179     WCHAR *dnW = NULL;
180     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
181
182     TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
183            clientctrls );
184
185     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
186
187     if (dn) {
188         dnW = strAtoW( dn );
189         if (!dnW) goto exit;
190     }
191     if (serverctrls) {
192         serverctrlsW = controlarrayAtoW( serverctrls );
193         if (!serverctrlsW) goto exit;
194     }
195     if (clientctrls) {
196         clientctrlsW = controlarrayAtoW( clientctrls );
197         if (!clientctrlsW) goto exit;
198     }
199
200     ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
201
202 exit:
203     strfreeW( dnW );
204     controlarrayfreeW( serverctrlsW );
205     controlarrayfreeW( clientctrlsW );
206
207 #endif
208     return ret;
209 }
210
211 ULONG ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
212     PLDAPControlW *clientctrls )
213 {
214     ULONG ret = LDAP_NOT_SUPPORTED;
215 #ifdef HAVE_LDAP
216     char *dnU = NULL;
217     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
218
219     TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
220            clientctrls );
221
222     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
223
224     if (dn) {
225         dnU = strWtoU( dn );
226         if (!dnU) goto exit;
227     }
228     if (serverctrls) {
229         serverctrlsU = controlarrayWtoU( serverctrls );
230         if (!serverctrlsU) goto exit;
231     }
232     if (clientctrls) {
233         clientctrlsU = controlarrayWtoU( clientctrls );
234         if (!clientctrlsU) goto exit;
235     }
236
237     ret = ldap_delete_ext_s( ld, dn ? dnU : "", serverctrlsU, clientctrlsU );
238
239 exit:
240     strfreeU( dnU );
241     controlarrayfreeU( serverctrlsU );
242     controlarrayfreeU( clientctrlsU );
243
244 #endif
245     return ret;
246 }
247  
248 ULONG ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
249 {
250     ULONG ret = LDAP_NOT_SUPPORTED;
251 #ifdef HAVE_LDAP
252     WCHAR *dnW = NULL;
253
254     TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
255
256     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
257
258     if (dn) {
259         dnW = strAtoW( dn );
260         if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
261     }
262
263     ret = ldap_delete_sW( ld, dnW );
264     strfreeW( dnW );
265
266 #endif
267     return ret;
268 }
269
270 ULONG ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
271 {
272     ULONG ret = LDAP_NOT_SUPPORTED;
273 #ifdef HAVE_LDAP
274     char *dnU = NULL;
275
276     TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
277
278     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
279
280     if (dn) {
281         dnU = strWtoU( dn );
282         if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
283     }
284
285     ret = ldap_delete_ext_s( ld, dn ? dnU : "", NULL, NULL );
286     strfreeU( dnU );
287
288 #endif
289     return ret;
290 }