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
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 /***********************************************************************
45 * ldap_close_extended_op (WLDAP32.@)
47 * Close an extended operation.
50 * ld [I] Pointer to an LDAP context.
51 * msgid [I] Message ID of the operation to be closed.
54 * Success: LDAP_SUCCESS
55 * Failure: An LDAP error code.
58 * Contrary to native, OpenLDAP does not require us to close
59 * extended operations, so this is a no-op.
61 ULONG CDECL
ldap_close_extended_op( WLDAP32_LDAP
*ld
, ULONG msgid
)
63 TRACE( "(%p, 0x%08x)\n", ld
, msgid
);
65 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
69 /***********************************************************************
70 * ldap_extended_operationA (WLDAP32.@)
72 * See ldap_extended_operationW.
74 ULONG CDECL
ldap_extended_operationA( WLDAP32_LDAP
*ld
, PCHAR oid
, struct WLDAP32_berval
*data
,
75 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
77 ULONG ret
= LDAP_NOT_SUPPORTED
;
80 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
82 ret
= WLDAP32_LDAP_NO_MEMORY
;
84 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(oid
), data
, serverctrls
,
85 clientctrls
, message
);
87 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
90 oidW
= strAtoW( oid
);
94 serverctrlsW
= controlarrayAtoW( serverctrls
);
95 if (!serverctrlsW
) goto exit
;
98 clientctrlsW
= controlarrayAtoW( clientctrls
);
99 if (!clientctrlsW
) goto exit
;
102 ret
= ldap_extended_operationW( ld
, oidW
, data
, serverctrlsW
, clientctrlsW
, message
);
106 controlarrayfreeW( serverctrlsW
);
107 controlarrayfreeW( clientctrlsW
);
113 /***********************************************************************
114 * ldap_extended_operationW (WLDAP32.@)
116 * Perform an extended operation (asynchronous mode).
119 * ld [I] Pointer to an LDAP context.
120 * oid [I] OID of the extended operation.
121 * data [I] Data needed by the operation.
122 * serverctrls [I] Array of LDAP server controls.
123 * clientctrls [I] Array of LDAP client controls.
124 * message [O] Message ID of the extended operation.
127 * Success: LDAP_SUCCESS
128 * Failure: An LDAP error code.
131 * The data parameter should be set to NULL if the operation
132 * requires no data. Call ldap_result with the message ID to
133 * get the result of the operation or ldap_abandon to cancel
134 * the operation. The serverctrls and clientctrls parameters
135 * are optional and should be set to NULL if not used. Call
136 * ldap_close_extended_op to close the operation.
138 ULONG CDECL
ldap_extended_operationW( WLDAP32_LDAP
*ld
, PWCHAR oid
, struct WLDAP32_berval
*data
,
139 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
141 ULONG ret
= LDAP_NOT_SUPPORTED
;
144 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
146 ret
= WLDAP32_LDAP_NO_MEMORY
;
148 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(oid
), data
, serverctrls
,
149 clientctrls
, message
);
151 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
154 oidU
= strWtoU( oid
);
155 if (!oidU
) goto exit
;
158 serverctrlsU
= controlarrayWtoU( serverctrls
);
159 if (!serverctrlsU
) goto exit
;
162 clientctrlsU
= controlarrayWtoU( clientctrls
);
163 if (!clientctrlsU
) goto exit
;
166 ret
= ldap_extended_operation( ld
, oid
? oidU
: "", (struct berval
*)data
,
167 serverctrlsU
, clientctrlsU
, (int *)message
);
171 controlarrayfreeU( serverctrlsU
);
172 controlarrayfreeU( clientctrlsU
);
178 /***********************************************************************
179 * ldap_extended_operation_sA (WLDAP32.@)
181 * See ldap_extended_operation_sW.
183 ULONG CDECL
ldap_extended_operation_sA( WLDAP32_LDAP
*ld
, PCHAR oid
, struct WLDAP32_berval
*data
,
184 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, PCHAR
*retoid
,
185 struct WLDAP32_berval
**retdata
)
187 ULONG ret
= LDAP_NOT_SUPPORTED
;
189 WCHAR
*oidW
= NULL
, *retoidW
= NULL
;
190 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
192 ret
= WLDAP32_LDAP_NO_MEMORY
;
194 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld
, debugstr_a(oid
), data
, serverctrls
,
195 clientctrls
, retoid
, retdata
);
197 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
200 oidW
= strAtoW( oid
);
201 if (!oidW
) goto exit
;
204 serverctrlsW
= controlarrayAtoW( serverctrls
);
205 if (!serverctrlsW
) goto exit
;
208 clientctrlsW
= controlarrayAtoW( clientctrls
);
209 if (!clientctrlsW
) goto exit
;
212 ret
= ldap_extended_operation_sW( ld
, oidW
, data
, serverctrlsW
, clientctrlsW
,
215 if (retoid
&& retoidW
) {
216 *retoid
= strWtoA( retoidW
);
217 if (!*retoid
) ret
= WLDAP32_LDAP_NO_MEMORY
;
218 ldap_memfreeW( retoidW
);
223 controlarrayfreeW( serverctrlsW
);
224 controlarrayfreeW( clientctrlsW
);
230 /***********************************************************************
231 * ldap_extended_operation_sW (WLDAP32.@)
233 * Perform an extended operation (synchronous mode).
236 * ld [I] Pointer to an LDAP context.
237 * oid [I] OID of the extended operation.
238 * data [I] Data needed by the operation.
239 * serverctrls [I] Array of LDAP server controls.
240 * clientctrls [I] Array of LDAP client controls.
241 * retoid [O] OID of the server response message.
242 * retdata [O] Data returned by the server.
245 * Success: LDAP_SUCCESS
246 * Failure: An LDAP error code.
249 * The data parameter should be set to NULL if the operation
250 * requires no data. The serverctrls, clientctrls, retoid and
251 * and retdata parameters are also optional. Set to NULL if not
252 * used. Free retoid and retdata after use with ldap_memfree.
254 ULONG CDECL
ldap_extended_operation_sW( WLDAP32_LDAP
*ld
, PWCHAR oid
, struct WLDAP32_berval
*data
,
255 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, PWCHAR
*retoid
,
256 struct WLDAP32_berval
**retdata
)
258 ULONG ret
= LDAP_NOT_SUPPORTED
;
260 char *oidU
= NULL
, *retoidU
= NULL
;
261 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
263 ret
= WLDAP32_LDAP_NO_MEMORY
;
265 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld
, debugstr_w(oid
), data
, serverctrls
,
266 clientctrls
, retoid
, retdata
);
268 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
271 oidU
= strWtoU( oid
);
272 if (!oidU
) goto exit
;
275 serverctrlsU
= controlarrayWtoU( serverctrls
);
276 if (!serverctrlsU
) goto exit
;
279 clientctrlsU
= controlarrayWtoU( clientctrls
);
280 if (!clientctrlsU
) goto exit
;
283 ret
= ldap_extended_operation_s( ld
, oid
? oidU
: "", (struct berval
*)data
, serverctrlsU
,
284 clientctrlsU
, &retoidU
, (struct berval
**)retdata
);
286 if (retoid
&& retoidU
) {
287 *retoid
= strUtoW( retoidU
);
288 if (!*retoid
) ret
= WLDAP32_LDAP_NO_MEMORY
;
289 ldap_memfree( retoidU
);
294 controlarrayfreeU( serverctrlsU
);
295 controlarrayfreeU( clientctrlsU
);