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"
34 static LDAPMod *nullmods[] = { NULL };
36 #define LDAP_NOT_SUPPORTED 0x5c
39 #include "winldap_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 ULONG ldap_modifyA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
46 ULONG ret = LDAP_NOT_SUPPORTED;
49 LDAPModW **modsW = NULL;
51 ret = WLDAP32_LDAP_NO_MEMORY;
53 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
62 modsW = modarrayAtoW( mods );
63 if (!modsW) goto exit;
66 ret = ldap_modifyW( ld, dnW, modsW );
70 modarrayfreeW( modsW );
76 ULONG ldap_modifyW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
78 ULONG ret = LDAP_NOT_SUPPORTED;
81 LDAPMod **modsU = NULL;
84 ret = WLDAP32_LDAP_NO_MEMORY;
86 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
88 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
95 modsU = modarrayWtoU( mods );
96 if (!modsU) goto exit;
99 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods,
102 if (ret == LDAP_SUCCESS)
109 modarrayfreeU( modsU );
115 ULONG ldap_modify_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
116 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
118 ULONG ret = LDAP_NOT_SUPPORTED;
121 LDAPModW **modsW = NULL;
122 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
124 ret = WLDAP32_LDAP_NO_MEMORY;
126 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
127 serverctrls, clientctrls, message );
129 if (!ld) return ~0UL;
136 modsW = modarrayAtoW( mods );
137 if (!modsW) goto exit;
140 serverctrlsW = controlarrayAtoW( serverctrls );
141 if (!serverctrlsW) goto exit;
144 clientctrlsW = controlarrayAtoW( clientctrls );
145 if (!clientctrlsW) goto exit;
148 ret = ldap_modify_extW( ld, dnW, modsW, serverctrlsW, clientctrlsW, message );
152 modarrayfreeW( modsW );
153 controlarrayfreeW( serverctrlsW );
154 controlarrayfreeW( clientctrlsW );
160 ULONG ldap_modify_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
161 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
163 ULONG ret = LDAP_NOT_SUPPORTED;
166 LDAPMod **modsU = NULL;
167 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
170 ret = WLDAP32_LDAP_NO_MEMORY;
172 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
173 serverctrls, clientctrls, message );
175 if (!ld) return ~0UL;
182 modsU = modarrayWtoU( mods );
183 if (!modsU) goto exit;
186 serverctrlsU = controlarrayWtoU( serverctrls );
187 if (!serverctrlsU) goto exit;
190 clientctrlsU = controlarrayWtoU( clientctrls );
191 if (!clientctrlsU) goto exit;
194 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods, serverctrlsU,
195 clientctrlsU, message ? (int *)message : &dummy );
199 modarrayfreeU( modsU );
200 controlarrayfreeU( serverctrlsU );
201 controlarrayfreeU( clientctrlsU );
207 ULONG ldap_modify_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
208 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
210 ULONG ret = LDAP_NOT_SUPPORTED;
213 LDAPModW **modsW = NULL;
214 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
216 ret = WLDAP32_LDAP_NO_MEMORY;
218 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
219 serverctrls, clientctrls );
221 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
228 modsW = modarrayAtoW( mods );
229 if (!modsW) goto exit;
232 serverctrlsW = controlarrayAtoW( serverctrls );
233 if (!serverctrlsW) goto exit;
236 clientctrlsW = controlarrayAtoW( clientctrls );
237 if (!clientctrlsW) goto exit;
240 ret = ldap_modify_ext_sW( ld, dnW, modsW, serverctrlsW, clientctrlsW );
244 modarrayfreeW( modsW );
245 controlarrayfreeW( serverctrlsW );
246 controlarrayfreeW( clientctrlsW );
252 ULONG ldap_modify_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
253 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
255 ULONG ret = LDAP_NOT_SUPPORTED;
258 LDAPMod **modsU = NULL;
259 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
261 ret = WLDAP32_LDAP_NO_MEMORY;
263 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
264 serverctrls, clientctrls );
266 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
273 modsU = modarrayWtoU( mods );
274 if (!modsU) goto exit;
277 serverctrlsU = controlarrayWtoU( serverctrls );
278 if (!serverctrlsU) goto exit;
281 clientctrlsU = controlarrayWtoU( clientctrls );
282 if (!clientctrlsU) goto exit;
285 ret = ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods,
286 serverctrlsU, clientctrlsU );
290 modarrayfreeU( modsU );
291 controlarrayfreeU( serverctrlsU );
292 controlarrayfreeU( clientctrlsU );
298 ULONG ldap_modify_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
300 ULONG ret = LDAP_NOT_SUPPORTED;
303 LDAPModW **modsW = NULL;
305 ret = WLDAP32_LDAP_NO_MEMORY;
307 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
309 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
316 modsW = modarrayAtoW( mods );
317 if (!modsW) goto exit;
320 ret = ldap_modify_sW( ld, dnW, modsW );
324 modarrayfreeW( modsW );
330 ULONG ldap_modify_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
332 ULONG ret = LDAP_NOT_SUPPORTED;
335 LDAPMod **modsU = NULL;
337 ret = WLDAP32_LDAP_NO_MEMORY;
339 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
341 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
348 modsU = modarrayWtoU( mods );
349 if (!modsU) goto exit;
352 ret = ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods, NULL, NULL );
356 modarrayfreeU( modsU );