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
26 #include "wine/debug.h"
27 #include "winldap_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
31 /***********************************************************************
32 * ldap_modifyA (WLDAP32.@)
34 ULONG CDECL
ldap_modifyA( LDAP
*ld
, char *dn
, LDAPModA
**mods
)
36 ULONG ret
= WLDAP32_LDAP_NO_MEMORY
;
38 LDAPModW
**modsW
= NULL
;
40 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
44 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
45 if (mods
&& !(modsW
= modarrayAtoW( mods
))) goto exit
;
47 ret
= ldap_modifyW( ld
, dnW
, modsW
);
51 modarrayfreeW( modsW
);
55 /***********************************************************************
56 * ldap_modifyW (WLDAP32.@)
58 ULONG CDECL
ldap_modifyW( LDAP
*ld
, WCHAR
*dn
, LDAPModW
**mods
)
62 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
64 ret
= ldap_modify_extW( ld
, dn
, mods
, NULL
, NULL
, &msg
);
65 if (ret
== WLDAP32_LDAP_SUCCESS
) return msg
;
69 /***********************************************************************
70 * ldap_modify_extA (WLDAP32.@)
72 ULONG CDECL
ldap_modify_extA( LDAP
*ld
, char *dn
, LDAPModA
**mods
, LDAPControlA
**serverctrls
,
73 LDAPControlA
**clientctrls
, ULONG
*message
)
75 ULONG ret
= WLDAP32_LDAP_NO_MEMORY
;
77 LDAPModW
**modsW
= NULL
;
78 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
80 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
, serverctrls
, clientctrls
, message
);
84 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
85 if (mods
&& !(modsW
= modarrayAtoW( mods
))) goto exit
;
86 if (serverctrls
&& !(serverctrlsW
= controlarrayAtoW( serverctrls
))) goto exit
;
87 if (clientctrls
&& !(clientctrlsW
= controlarrayAtoW( clientctrls
))) goto exit
;
89 ret
= ldap_modify_extW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
, message
);
93 modarrayfreeW( modsW
);
94 controlarrayfreeW( serverctrlsW
);
95 controlarrayfreeW( clientctrlsW
);
99 /***********************************************************************
100 * ldap_modify_extW (WLDAP32.@)
102 ULONG CDECL
ldap_modify_extW( LDAP
*ld
, WCHAR
*dn
, LDAPModW
**mods
, LDAPControlW
**serverctrls
,
103 LDAPControlW
**clientctrls
, ULONG
*message
)
105 ULONG ret
= WLDAP32_LDAP_NO_MEMORY
;
107 LDAPMod
**modsU
= NULL
;
108 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
110 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
, serverctrls
, clientctrls
, message
);
114 if (dn
&& !(dnU
= strWtoU( dn
))) goto exit
;
115 if (mods
&& !(modsU
= modarrayWtoU( mods
))) goto exit
;
116 if (serverctrls
&& !(serverctrlsU
= controlarrayWtoU( serverctrls
))) goto exit
;
117 if (clientctrls
&& !(clientctrlsU
= controlarrayWtoU( clientctrls
))) goto exit
;
120 ret
= map_error( ldap_modify_ext( CTX(ld
), dnU
, modsU
, serverctrlsU
, clientctrlsU
, (int *)message
) );
125 modarrayfreeU( modsU
);
126 controlarrayfreeU( serverctrlsU
);
127 controlarrayfreeU( clientctrlsU
);
131 /***********************************************************************
132 * ldap_modify_ext_sA (WLDAP32.@)
134 ULONG CDECL
ldap_modify_ext_sA( LDAP
*ld
, char *dn
, LDAPModA
**mods
, LDAPControlA
**serverctrls
,
135 LDAPControlA
**clientctrls
)
137 ULONG ret
= WLDAP32_LDAP_NO_MEMORY
;
139 LDAPModW
**modsW
= NULL
;
140 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
142 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_a(dn
), mods
, serverctrls
, clientctrls
);
144 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
146 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
147 if (mods
&& !(modsW
= modarrayAtoW( mods
))) goto exit
;
148 if (serverctrls
&& !(serverctrlsW
= controlarrayAtoW( serverctrls
))) goto exit
;
149 if (clientctrls
&& !(clientctrlsW
= controlarrayAtoW( clientctrls
))) goto exit
;
151 ret
= ldap_modify_ext_sW( ld
, dnW
, modsW
, serverctrlsW
, clientctrlsW
);
155 modarrayfreeW( modsW
);
156 controlarrayfreeW( serverctrlsW
);
157 controlarrayfreeW( clientctrlsW
);
161 /***********************************************************************
162 * ldap_modify_ext_sW (WLDAP32.@)
164 ULONG CDECL
ldap_modify_ext_sW( LDAP
*ld
, WCHAR
*dn
, LDAPModW
**mods
, LDAPControlW
**serverctrls
,
165 LDAPControlW
**clientctrls
)
167 ULONG ret
= WLDAP32_LDAP_NO_MEMORY
;
169 LDAPMod
**modsU
= NULL
;
170 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
172 TRACE( "(%p, %s, %p, %p, %p)\n", ld
, debugstr_w(dn
), mods
, serverctrls
, clientctrls
);
174 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
176 if (dn
&& !(dnU
= strWtoU( dn
))) goto exit
;
177 if (mods
&& !(modsU
= modarrayWtoU( mods
))) goto exit
;
178 if (serverctrls
&& !(serverctrlsU
= controlarrayWtoU( serverctrls
))) goto exit
;
179 if (clientctrls
&& !(clientctrlsU
= controlarrayWtoU( clientctrls
))) goto exit
;
182 ret
= map_error( ldap_modify_ext_s( CTX(ld
), dnU
, modsU
, serverctrlsU
, clientctrlsU
) );
187 modarrayfreeU( modsU
);
188 controlarrayfreeU( serverctrlsU
);
189 controlarrayfreeU( clientctrlsU
);
193 /***********************************************************************
194 * ldap_modify_sA (WLDAP32.@)
196 ULONG CDECL
ldap_modify_sA( LDAP
*ld
, char *dn
, LDAPModA
**mods
)
198 ULONG ret
= WLDAP32_LDAP_NO_MEMORY
;
200 LDAPModW
**modsW
= NULL
;
202 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), mods
);
204 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
206 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
207 if (mods
&& !(modsW
= modarrayAtoW( mods
))) goto exit
;
209 ret
= ldap_modify_sW( ld
, dnW
, modsW
);
213 modarrayfreeW( modsW
);
217 /***********************************************************************
218 * ldap_modify_sW (WLDAP32.@)
220 ULONG CDECL
ldap_modify_sW( LDAP
*ld
, WCHAR
*dn
, LDAPModW
**mods
)
222 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), mods
);
223 return ldap_modify_ext_sW( ld
, dn
, mods
, NULL
, NULL
);