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"
36 #include "winldap_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
41 /***********************************************************************
42 * ldap_close_extended_op (WLDAP32.@)
44 * Close an extended operation.
47 * ld [I] Pointer to an LDAP context.
48 * msgid [I] Message ID of the operation to be closed.
51 * Success: LDAP_SUCCESS
52 * Failure: An LDAP error code.
55 * Contrary to native, OpenLDAP does not require us to close
56 * extended operations, so this is a no-op.
58 ULONG CDECL
ldap_close_extended_op( WLDAP32_LDAP
*ld
, ULONG msgid
)
60 TRACE( "(%p, 0x%08x)\n", ld
, msgid
);
62 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
63 return WLDAP32_LDAP_SUCCESS
;
66 /***********************************************************************
67 * ldap_extended_operationA (WLDAP32.@)
69 * See ldap_extended_operationW.
71 ULONG CDECL
ldap_extended_operationA( WLDAP32_LDAP
*ld
, PCHAR oid
, struct WLDAP32_berval
*data
,
72 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, ULONG
*message
)
74 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
77 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
79 ret
= WLDAP32_LDAP_NO_MEMORY
;
81 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_a(oid
), data
, serverctrls
,
82 clientctrls
, message
);
84 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
87 oidW
= strAtoW( oid
);
91 serverctrlsW
= controlarrayAtoW( serverctrls
);
92 if (!serverctrlsW
) goto exit
;
95 clientctrlsW
= controlarrayAtoW( clientctrls
);
96 if (!clientctrlsW
) goto exit
;
99 ret
= ldap_extended_operationW( ld
, oidW
, data
, serverctrlsW
, clientctrlsW
, message
);
103 controlarrayfreeW( serverctrlsW
);
104 controlarrayfreeW( clientctrlsW
);
110 /***********************************************************************
111 * ldap_extended_operationW (WLDAP32.@)
113 * Perform an extended operation (asynchronous mode).
116 * ld [I] Pointer to an LDAP context.
117 * oid [I] OID of the extended operation.
118 * data [I] Data needed by the operation.
119 * serverctrls [I] Array of LDAP server controls.
120 * clientctrls [I] Array of LDAP client controls.
121 * message [O] Message ID of the extended operation.
124 * Success: LDAP_SUCCESS
125 * Failure: An LDAP error code.
128 * The data parameter should be set to NULL if the operation
129 * requires no data. Call ldap_result with the message ID to
130 * get the result of the operation or ldap_abandon to cancel
131 * the operation. The serverctrls and clientctrls parameters
132 * are optional and should be set to NULL if not used. Call
133 * ldap_close_extended_op to close the operation.
135 ULONG CDECL
ldap_extended_operationW( WLDAP32_LDAP
*ld
, PWCHAR oid
, struct WLDAP32_berval
*data
,
136 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, ULONG
*message
)
138 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
141 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
143 ret
= WLDAP32_LDAP_NO_MEMORY
;
145 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld
, debugstr_w(oid
), data
, serverctrls
,
146 clientctrls
, message
);
148 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
151 oidU
= strWtoU( oid
);
152 if (!oidU
) goto exit
;
155 serverctrlsU
= controlarrayWtoU( serverctrls
);
156 if (!serverctrlsU
) goto exit
;
159 clientctrlsU
= controlarrayWtoU( clientctrls
);
160 if (!clientctrlsU
) goto exit
;
163 ret
= map_error( ldap_extended_operation( ld
, oid
? oidU
: "", (struct berval
*)data
,
164 serverctrlsU
, clientctrlsU
, (int *)message
));
168 controlarrayfreeU( serverctrlsU
);
169 controlarrayfreeU( clientctrlsU
);
175 /***********************************************************************
176 * ldap_extended_operation_sA (WLDAP32.@)
178 * See ldap_extended_operation_sW.
180 ULONG CDECL
ldap_extended_operation_sA( WLDAP32_LDAP
*ld
, PCHAR oid
, struct WLDAP32_berval
*data
,
181 PLDAPControlA
*serverctrls
, PLDAPControlA
*clientctrls
, PCHAR
*retoid
,
182 struct WLDAP32_berval
**retdata
)
184 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
186 WCHAR
*oidW
= NULL
, *retoidW
= NULL
;
187 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
189 ret
= WLDAP32_LDAP_NO_MEMORY
;
191 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld
, debugstr_a(oid
), data
, serverctrls
,
192 clientctrls
, retoid
, retdata
);
194 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
197 oidW
= strAtoW( oid
);
198 if (!oidW
) goto exit
;
201 serverctrlsW
= controlarrayAtoW( serverctrls
);
202 if (!serverctrlsW
) goto exit
;
205 clientctrlsW
= controlarrayAtoW( clientctrls
);
206 if (!clientctrlsW
) goto exit
;
209 ret
= ldap_extended_operation_sW( ld
, oidW
, data
, serverctrlsW
, clientctrlsW
,
212 if (retoid
&& retoidW
) {
213 *retoid
= strWtoA( retoidW
);
214 if (!*retoid
) ret
= WLDAP32_LDAP_NO_MEMORY
;
215 ldap_memfreeW( retoidW
);
220 controlarrayfreeW( serverctrlsW
);
221 controlarrayfreeW( clientctrlsW
);
227 /***********************************************************************
228 * ldap_extended_operation_sW (WLDAP32.@)
230 * Perform an extended operation (synchronous mode).
233 * ld [I] Pointer to an LDAP context.
234 * oid [I] OID of the extended operation.
235 * data [I] Data needed by the operation.
236 * serverctrls [I] Array of LDAP server controls.
237 * clientctrls [I] Array of LDAP client controls.
238 * retoid [O] OID of the server response message.
239 * retdata [O] Data returned by the server.
242 * Success: LDAP_SUCCESS
243 * Failure: An LDAP error code.
246 * The data parameter should be set to NULL if the operation
247 * requires no data. The serverctrls, clientctrls, retoid and
248 * and retdata parameters are also optional. Set to NULL if not
249 * used. Free retoid and retdata after use with ldap_memfree.
251 ULONG CDECL
ldap_extended_operation_sW( WLDAP32_LDAP
*ld
, PWCHAR oid
, struct WLDAP32_berval
*data
,
252 PLDAPControlW
*serverctrls
, PLDAPControlW
*clientctrls
, PWCHAR
*retoid
,
253 struct WLDAP32_berval
**retdata
)
255 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
257 char *oidU
= NULL
, *retoidU
= NULL
;
258 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
260 ret
= WLDAP32_LDAP_NO_MEMORY
;
262 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld
, debugstr_w(oid
), data
, serverctrls
,
263 clientctrls
, retoid
, retdata
);
265 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
268 oidU
= strWtoU( oid
);
269 if (!oidU
) goto exit
;
272 serverctrlsU
= controlarrayWtoU( serverctrls
);
273 if (!serverctrlsU
) goto exit
;
276 clientctrlsU
= controlarrayWtoU( clientctrls
);
277 if (!clientctrlsU
) goto exit
;
280 ret
= map_error( ldap_extended_operation_s( ld
, oid
? oidU
: "", (struct berval
*)data
, serverctrlsU
,
281 clientctrlsU
, &retoidU
, (struct berval
**)retdata
));
283 if (retoid
&& retoidU
) {
284 *retoid
= strUtoW( retoidU
);
285 if (!*retoid
) ret
= WLDAP32_LDAP_NO_MEMORY
;
286 ldap_memfree( retoidU
);
291 controlarrayfreeU( serverctrlsU
);
292 controlarrayfreeU( clientctrlsU
);