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
;
83 ret
= WLDAP32_LDAP_NO_MEMORY
;
85 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
87 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
94 modsU
= modarrayWtoU( mods
);
95 if (!modsU
) goto exit
;
98 ret
= ldap_modify( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
);
102 modarrayfreeU( modsU
);
108 ULONG
ldap_modify_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
109 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
111 ULONG ret
= LDAP_NOT_SUPPORTED
;
114 LDAPModW
**modsW
= NULL
;
115 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
117 ret
= WLDAP32_LDAP_NO_MEMORY
;
119 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
120 serverctrls
, clientctrls
, message
);
122 if (!ld
) return ~0UL;
129 modsW
= modarrayAtoW( mods
);
130 if (!modsW
) goto exit
;
133 serverctrlsW
= controlarrayAtoW( serverctrls
);
134 if (!serverctrlsW
) goto exit
;
137 clientctrlsW
= controlarrayAtoW( clientctrls
);
138 if (!clientctrlsW
) goto exit
;
141 ret
= ldap_modify_extW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
, message
);
145 modarrayfreeW( modsW
);
146 controlarrayfreeW( serverctrlsW
);
147 controlarrayfreeW( clientctrlsW
);
153 ULONG
ldap_modify_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
154 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
156 ULONG ret
= LDAP_NOT_SUPPORTED
;
159 LDAPMod
**modsU
= 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
), mods
,
166 serverctrls
, clientctrls
, message
);
168 if (!ld
) return ~0UL;
175 modsU
= modarrayWtoU( mods
);
176 if (!modsU
) goto exit
;
179 serverctrlsU
= controlarrayWtoU( serverctrls
);
180 if (!serverctrlsU
) goto exit
;
183 clientctrlsU
= controlarrayWtoU( clientctrls
);
184 if (!clientctrlsU
) goto exit
;
187 ret
= ldap_modify_ext( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
, serverctrlsU
,
188 clientctrlsU
, message
? (int *)message
: &dummy
);
192 modarrayfreeU( modsU
);
193 controlarrayfreeU( serverctrlsU
);
194 controlarrayfreeU( clientctrlsU
);
200 ULONG
ldap_modify_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[],
201 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
)
203 ULONG ret
= LDAP_NOT_SUPPORTED
;
206 LDAPModW
**modsW
= NULL
;
207 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
209 ret
= WLDAP32_LDAP_NO_MEMORY
;
211 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
,
212 serverctrls
, clientctrls
);
214 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
221 modsW
= modarrayAtoW( mods
);
222 if (!modsW
) goto exit
;
225 serverctrlsW
= controlarrayAtoW( serverctrls
);
226 if (!serverctrlsW
) goto exit
;
229 clientctrlsW
= controlarrayAtoW( clientctrls
);
230 if (!clientctrlsW
) goto exit
;
233 ret
= ldap_modify_ext_sW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
);
237 modarrayfreeW( modsW
);
238 controlarrayfreeW( serverctrlsW
);
239 controlarrayfreeW( clientctrlsW
);
245 ULONG
ldap_modify_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[],
246 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
)
248 ULONG ret
= LDAP_NOT_SUPPORTED
;
251 LDAPMod
**modsU
= NULL
;
252 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
254 ret
= WLDAP32_LDAP_NO_MEMORY
;
256 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
,
257 serverctrls
, clientctrls
);
259 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
266 modsU
= modarrayWtoU( mods
);
267 if (!modsU
) goto exit
;
270 serverctrlsU
= controlarrayWtoU( serverctrls
);
271 if (!serverctrlsU
) goto exit
;
274 clientctrlsU
= controlarrayWtoU( clientctrls
);
275 if (!clientctrlsU
) goto exit
;
278 ret
= ldap_modify_ext_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
,
279 serverctrlsU
, clientctrlsU
);
283 modarrayfreeU( modsU
);
284 controlarrayfreeU( serverctrlsU
);
285 controlarrayfreeU( clientctrlsU
);
291 ULONG
ldap_modify_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, LDAPModA
*mods
[] )
293 ULONG ret
= LDAP_NOT_SUPPORTED
;
296 LDAPModW
**modsW
= NULL
;
298 ret
= WLDAP32_LDAP_NO_MEMORY
;
300 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
302 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
309 modsW
= modarrayAtoW( mods
);
310 if (!modsW
) goto exit
;
313 ret
= ldap_modify_sW( ld
, dnW
, modsW
);
317 modarrayfreeW( modsW
);
323 ULONG
ldap_modify_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, LDAPModW
*mods
[] )
325 ULONG ret
= LDAP_NOT_SUPPORTED
;
328 LDAPMod
**modsU
= NULL
;
330 ret
= WLDAP32_LDAP_NO_MEMORY
;
332 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
334 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
341 modsU
= modarrayWtoU( mods
);
342 if (!modsU
) goto exit
;
345 ret
= ldap_modify_s( ld
, dn
? dnU
: "", mods
? modsU
: nullmods
);
349 modarrayfreeU( modsU
);