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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
24 #include "wine/debug.h"
35 #define LDAP_NOT_SUPPORTED 0x5c
38 #include "winldap_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43 ULONG ldap_addA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[] )
45 ULONG ret = LDAP_NOT_SUPPORTED;
48 LDAPModW **attrsW = NULL;
50 ret = WLDAP32_LDAP_NO_MEMORY;
52 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
55 if (!attrs) return LDAP_PROTOCOL_ERROR;
62 attrsW = modarrayAtoW( attrs );
63 if (!attrsW) goto exit;
65 ret = ldap_addW( ld, dnW, attrsW );
69 modarrayfreeW( attrsW );
75 ULONG ldap_addW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
77 ULONG ret = LDAP_NOT_SUPPORTED;
80 LDAPMod **attrsU = NULL;
82 ret = WLDAP32_LDAP_NO_MEMORY;
84 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
86 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
87 if (!attrs) return LDAP_PROTOCOL_ERROR;
94 attrsU = modarrayWtoU( attrs );
95 if (!attrsU) goto exit;
97 ret = ldap_add( ld, dn ? dnU : "", attrsU );
101 modarrayfreeU( attrsU );
107 ULONG ldap_add_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[],
108 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
110 ULONG ret = LDAP_NOT_SUPPORTED;
113 LDAPModW **attrsW = NULL;
114 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
116 ret = WLDAP32_LDAP_NO_MEMORY;
118 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), attrs,
119 serverctrls, clientctrls, message );
121 if (!ld) return ~0UL;
122 if (!attrs) return LDAP_PROTOCOL_ERROR;
129 attrsW = modarrayAtoW( attrs );
130 if (!attrsW) goto exit;
133 serverctrlsW = controlarrayAtoW( serverctrls );
134 if (!serverctrlsW) goto exit;
137 clientctrlsW = controlarrayAtoW( clientctrls );
138 if (!clientctrlsW) goto exit;
141 ret = ldap_add_extW( ld, dnW, attrsW, serverctrlsW, clientctrlsW, message );
145 modarrayfreeW( attrsW );
146 controlarrayfreeW( serverctrlsW );
147 controlarrayfreeW( clientctrlsW );
153 ULONG ldap_add_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[],
154 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
156 ULONG ret = LDAP_NOT_SUPPORTED;
159 LDAPMod **attrsU = NULL;
160 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
163 ret = WLDAP32_LDAP_NO_MEMORY;
165 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), attrs,
166 serverctrls, clientctrls, message );
168 if (!ld) return ~0UL;
169 if (!attrs) return LDAP_PROTOCOL_ERROR;
176 attrsU = modarrayWtoU( attrs );
177 if (!attrsU) goto exit;
180 serverctrlsU = controlarrayWtoU( serverctrls );
181 if (!serverctrlsU) goto exit;
184 clientctrlsU = controlarrayWtoU( clientctrls );
185 if (!clientctrlsU) goto exit;
188 ret = ldap_add_ext( ld, dn ? dnU : "", attrsU, serverctrlsU, clientctrlsU,
189 message ? (int *)message : &dummy );
193 modarrayfreeU( attrsU );
194 controlarrayfreeU( serverctrlsU );
195 controlarrayfreeU( clientctrlsU );
201 ULONG ldap_add_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[],
202 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
204 ULONG ret = LDAP_NOT_SUPPORTED;
207 LDAPModW **attrsW = NULL;
208 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
210 ret = WLDAP32_LDAP_NO_MEMORY;
212 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), attrs,
213 serverctrls, clientctrls );
215 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
216 if (!attrs) return LDAP_PROTOCOL_ERROR;
223 attrsW = modarrayAtoW( attrs );
224 if (!attrsW) goto exit;
227 serverctrlsW = controlarrayAtoW( serverctrls );
228 if (!serverctrlsW) goto exit;
231 clientctrlsW = controlarrayAtoW( clientctrls );
232 if (!clientctrlsW) goto exit;
235 ret = ldap_add_ext_sW( ld, dnW, attrsW, serverctrlsW, clientctrlsW );
239 modarrayfreeW( attrsW );
240 controlarrayfreeW( serverctrlsW );
241 controlarrayfreeW( clientctrlsW );
247 ULONG ldap_add_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[],
248 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
250 ULONG ret = LDAP_NOT_SUPPORTED;
253 LDAPMod **attrsU = NULL;
254 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
256 ret = WLDAP32_LDAP_NO_MEMORY;
258 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), attrs,
259 serverctrls, clientctrls );
261 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
262 if (!attrs) return LDAP_PROTOCOL_ERROR;
269 attrsU = modarrayWtoU( attrs );
270 if (!attrsU) goto exit;
273 serverctrlsU = controlarrayWtoU( serverctrls );
274 if (!serverctrlsU) goto exit;
277 clientctrlsU = controlarrayWtoU( clientctrls );
278 if (!clientctrlsU) goto exit;
281 ret = ldap_add_ext_s( ld, dn ? dnU : "", attrsU, serverctrlsU, clientctrlsU );
285 modarrayfreeU( attrsU );
286 controlarrayfreeU( serverctrlsU );
287 controlarrayfreeU( clientctrlsU );
293 ULONG ldap_add_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[] )
295 ULONG ret = LDAP_NOT_SUPPORTED;
298 LDAPModW **attrsW = NULL;
300 ret = WLDAP32_LDAP_NO_MEMORY;
302 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
304 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
305 if (!attrs) return LDAP_PROTOCOL_ERROR;
312 attrsW = modarrayAtoW( attrs );
313 if (!attrsW) goto exit;
315 ret = ldap_add_sW( ld, dnW, attrsW );
319 modarrayfreeW( attrsW );
325 ULONG ldap_add_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
327 ULONG ret = LDAP_NOT_SUPPORTED;
330 LDAPMod **attrsU = NULL;
332 ret = WLDAP32_LDAP_NO_MEMORY;
334 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
336 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
337 if (!attrs) return LDAP_PROTOCOL_ERROR;
344 attrsU = modarrayWtoU( attrs );
345 if (!attrsU) goto exit;
347 ret = ldap_add_s( ld, dn ? dnU : "", attrsU );
351 modarrayfreeU( attrsU );