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_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
39 #include "winldap_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
44 ULONG
ldap_close_extended_op( WLDAP32_LDAP
*ld
, ULONG msgid
)
46 TRACE( "(%p, 0x%08lx)\n", ld
, msgid
);
48 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
52 ULONG
ldap_extended_operationA( WLDAP32_LDAP
*ld
, PCHAR oid
, struct WLDAP32_berval
*data
,
53 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
55 ULONG ret
= LDAP_NOT_SUPPORTED
;
58 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
60 ret
= WLDAP32_LDAP_NO_MEMORY
;
62 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(oid
), data
, serverctrls
,
63 clientctrls
, message
);
65 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
68 oidW
= strAtoW( oid
);
72 serverctrlsW
= controlarrayAtoW( serverctrls
);
73 if (!serverctrlsW
) goto exit
;
76 clientctrlsW
= controlarrayAtoW( clientctrls
);
77 if (!clientctrlsW
) goto exit
;
80 ret
= ldap_extended_operationW( ld
, oidW
, data
, serverctrlsW
, clientctrlsW
, message
);
84 controlarrayfreeW( serverctrlsW
);
85 controlarrayfreeW( clientctrlsW
);
91 ULONG
ldap_extended_operationW( WLDAP32_LDAP
*ld
, PWCHAR oid
, struct WLDAP32_berval
*data
,
92 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
94 ULONG ret
= LDAP_NOT_SUPPORTED
;
97 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
99 ret
= WLDAP32_LDAP_NO_MEMORY
;
101 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(oid
), data
, serverctrls
,
102 clientctrls
, message
);
104 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
107 oidU
= strWtoU( oid
);
108 if (!oidU
) goto exit
;
111 serverctrlsU
= controlarrayWtoU( serverctrls
);
112 if (!serverctrlsU
) goto exit
;
115 clientctrlsU
= controlarrayWtoU( clientctrls
);
116 if (!clientctrlsU
) goto exit
;
119 ret
= ldap_extended_operation( ld
, oid
? oidU
: "", (struct berval
*)data
,
120 serverctrlsU
, clientctrlsU
, (int *)message
);
124 controlarrayfreeU( serverctrlsU
);
125 controlarrayfreeU( clientctrlsU
);
131 ULONG
ldap_extended_operation_sA( WLDAP32_LDAP
*ld
, PCHAR oid
, struct WLDAP32_berval
*data
,
132 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, PCHAR
*retoid
,
133 struct WLDAP32_berval
**retdata
)
135 ULONG ret
= LDAP_NOT_SUPPORTED
;
137 WCHAR
*oidW
= NULL
, *retoidW
= NULL
;
138 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
140 ret
= WLDAP32_LDAP_NO_MEMORY
;
142 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld
, debugstr_a(oid
), data
, serverctrls
,
143 clientctrls
, retoid
, retdata
);
145 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
148 oidW
= strAtoW( oid
);
149 if (!oidW
) goto exit
;
152 serverctrlsW
= controlarrayAtoW( serverctrls
);
153 if (!serverctrlsW
) goto exit
;
156 clientctrlsW
= controlarrayAtoW( clientctrls
);
157 if (!clientctrlsW
) goto exit
;
160 ret
= ldap_extended_operation_sW( ld
, oidW
, data
, serverctrlsW
, clientctrlsW
,
163 if (retoid
&& retoidW
) {
164 *retoid
= strWtoA( retoidW
);
165 if (!*retoid
) ret
= WLDAP32_LDAP_NO_MEMORY
;
166 ldap_memfreeW( retoidW
);
171 controlarrayfreeW( serverctrlsW
);
172 controlarrayfreeW( clientctrlsW
);
178 ULONG
ldap_extended_operation_sW( WLDAP32_LDAP
*ld
, PWCHAR oid
, struct WLDAP32_berval
*data
,
179 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, PWCHAR
*retoid
,
180 struct WLDAP32_berval
**retdata
)
182 ULONG ret
= LDAP_NOT_SUPPORTED
;
184 char *oidU
= NULL
, *retoidU
= NULL
;
185 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
187 ret
= WLDAP32_LDAP_NO_MEMORY
;
189 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld
, debugstr_w(oid
), data
, serverctrls
,
190 clientctrls
, retoid
, retdata
);
192 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
195 oidU
= strWtoU( oid
);
196 if (!oidU
) goto exit
;
199 serverctrlsU
= controlarrayWtoU( serverctrls
);
200 if (!serverctrlsU
) goto exit
;
203 clientctrlsU
= controlarrayWtoU( clientctrls
);
204 if (!clientctrlsU
) goto exit
;
207 ret
= ldap_extended_operation_s( ld
, oid
? oidU
: "", (struct berval
*)data
, serverctrlsU
,
208 clientctrlsU
, &retoidU
, (struct berval
**)retdata
);
210 if (retoid
&& retoidU
) {
211 *retoid
= strUtoW( retoidU
);
212 if (!*retoid
) ret
= WLDAP32_LDAP_NO_MEMORY
;
213 ldap_memfree( retoidU
);
218 controlarrayfreeU( serverctrlsU
);
219 controlarrayfreeU( clientctrlsU
);