2005-07-19 22:32:46 +02:00
|
|
|
/*
|
|
|
|
* WLDAP32 - LDAP support for Wine
|
|
|
|
*
|
|
|
|
* Copyright 2005 Hans Leidekker
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-19 22:32:46 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-09-05 17:23:34 +02:00
|
|
|
#ifdef HAVE_LDAP_H
|
|
|
|
#include <ldap.h>
|
|
|
|
#endif
|
2020-03-23 14:14:15 +01:00
|
|
|
#ifdef HAVE_SASL_SASL_H
|
|
|
|
#include <sasl/sasl.h>
|
|
|
|
#endif
|
2005-07-19 22:32:46 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
2020-03-23 14:14:15 +01:00
|
|
|
#include "rpc.h"
|
2005-07-19 22:32:46 +02:00
|
|
|
|
|
|
|
#include "winldap_private.h"
|
|
|
|
#include "wldap32.h"
|
2011-09-05 17:23:34 +02:00
|
|
|
#include "wine/debug.h"
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2020-02-05 21:44:14 +01:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-19 22:32:46 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
2020-02-05 21:44:14 +01:00
|
|
|
#endif
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_bindA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_bindW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_bindA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR cred, ULONG method )
|
2005-07-19 22:32:46 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-19 22:32:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
WCHAR *dnW = NULL, *credW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), cred, method );
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnW = strAtoW( dn );
|
|
|
|
if (!dnW) goto exit;
|
|
|
|
}
|
|
|
|
if (cred) {
|
|
|
|
credW = strAtoW( cred );
|
|
|
|
if (!credW) goto exit;
|
|
|
|
}
|
2005-07-19 22:32:46 +02:00
|
|
|
|
|
|
|
ret = ldap_bindW( ld, dnW, credW, method );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-19 22:32:46 +02:00
|
|
|
strfreeW( dnW );
|
|
|
|
strfreeW( credW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_bindW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Authenticate with an LDAP server (asynchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of entry to bind as.
|
|
|
|
* cred [I] Credentials (e.g. password string).
|
|
|
|
* method [I] Authentication method.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Message ID of the bind operation.
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
2005-12-02 11:26:19 +01:00
|
|
|
* Only LDAP_AUTH_SIMPLE is supported (just like native).
|
2005-11-28 20:41:08 +01:00
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
|
2005-07-19 22:32:46 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-19 22:32:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
char *dnU = NULL, *credU = NULL;
|
2005-11-18 16:05:01 +01:00
|
|
|
struct berval pwd = { 0, NULL };
|
|
|
|
int msg;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), cred, method );
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-11-18 16:05:01 +01:00
|
|
|
if (method != LDAP_AUTH_SIMPLE) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnU = strWtoU( dn );
|
|
|
|
if (!dnU) goto exit;
|
|
|
|
}
|
|
|
|
if (cred) {
|
|
|
|
credU = strWtoU( cred );
|
|
|
|
if (!credU) goto exit;
|
2005-11-18 16:05:01 +01:00
|
|
|
|
|
|
|
pwd.bv_len = strlen( credU );
|
|
|
|
pwd.bv_val = credU;
|
2005-07-26 12:30:49 +02:00
|
|
|
}
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = ldap_sasl_bind( ld->ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );
|
2005-11-18 16:05:01 +01:00
|
|
|
|
|
|
|
if (ret == LDAP_SUCCESS)
|
|
|
|
ret = msg;
|
|
|
|
else
|
2009-01-05 12:40:28 +01:00
|
|
|
ret = ~0u;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-19 22:32:46 +02:00
|
|
|
strfreeU( dnU );
|
|
|
|
strfreeU( credU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_bind_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_bind_sW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_bind_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR cred, ULONG method )
|
2005-07-19 22:32:46 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-19 22:32:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
WCHAR *dnW = NULL, *credW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), cred, method );
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnW = strAtoW( dn );
|
|
|
|
if (!dnW) goto exit;
|
|
|
|
}
|
|
|
|
if (cred) {
|
2020-03-23 14:14:15 +01:00
|
|
|
if (method == LDAP_AUTH_SIMPLE)
|
|
|
|
{
|
|
|
|
credW = strAtoW( cred );
|
|
|
|
if (!credW) goto exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
credW = (WCHAR *)cred /* SEC_WINNT_AUTH_IDENTITY_A */;
|
2005-07-26 12:30:49 +02:00
|
|
|
}
|
2005-07-19 22:32:46 +02:00
|
|
|
|
|
|
|
ret = ldap_bind_sW( ld, dnW, credW, method );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-19 22:32:46 +02:00
|
|
|
strfreeW( dnW );
|
2020-03-23 14:14:15 +01:00
|
|
|
if (credW != (WCHAR *)cred) strfreeW( credW );
|
2005-07-19 22:32:46 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-30 03:55:38 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2020-03-23 14:14:15 +01:00
|
|
|
|
|
|
|
static int sasl_interact( LDAP *ld, unsigned flags, void *defaults, void *interact )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SASL_SASL_H
|
|
|
|
SEC_WINNT_AUTH_IDENTITY_A *id = defaults;
|
|
|
|
sasl_interact_t *sasl = interact;
|
|
|
|
|
|
|
|
TRACE( "%p,%08x,%p,%p\n", ld, flags, defaults, interact );
|
|
|
|
|
|
|
|
while (sasl->id != SASL_CB_LIST_END)
|
|
|
|
{
|
|
|
|
TRACE("sasl->id = %04lx\n", sasl->id);
|
|
|
|
|
|
|
|
if (sasl->id == SASL_CB_GETREALM)
|
|
|
|
{
|
|
|
|
sasl->result = id->Domain;
|
|
|
|
sasl->len = id->DomainLength;
|
|
|
|
}
|
|
|
|
else if (sasl->id == SASL_CB_USER)
|
|
|
|
{
|
|
|
|
sasl->result = id->User;
|
|
|
|
sasl->len = id->UserLength;
|
|
|
|
}
|
|
|
|
else if (sasl->id == SASL_CB_PASS)
|
|
|
|
{
|
|
|
|
sasl->result = id->Password;
|
|
|
|
sasl->len = id->PasswordLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
sasl++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LDAP_SUCCESS;
|
|
|
|
#else
|
|
|
|
FIXME( "%p,%08x,%p,%p: stub\n", ld, flags, defaults, interact );
|
|
|
|
return LDAP_SUCCESS;
|
|
|
|
#endif /* HAVE_SASL_SASL_H */
|
|
|
|
}
|
|
|
|
|
2020-03-30 03:55:38 +02:00
|
|
|
#endif /* HAVE_LDAP */
|
2020-03-23 14:14:15 +01:00
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_bind_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Authenticate with an LDAP server (synchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of entry to bind as.
|
|
|
|
* cred [I] Credentials (e.g. password string).
|
|
|
|
* method [I] Authentication method.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
|
2005-07-19 22:32:46 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-19 22:32:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
char *dnU = NULL, *credU = NULL;
|
2005-11-18 16:05:01 +01:00
|
|
|
struct berval pwd = { 0, NULL };
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2006-09-30 12:07:23 +02:00
|
|
|
TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), cred, method );
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2020-03-23 14:14:15 +01:00
|
|
|
if (method == LDAP_AUTH_SIMPLE)
|
|
|
|
{
|
|
|
|
if (dn)
|
|
|
|
{
|
|
|
|
dnU = strWtoU( dn );
|
|
|
|
if (!dnU) goto exit;
|
|
|
|
}
|
|
|
|
if (cred)
|
|
|
|
{
|
|
|
|
credU = strWtoU( cred );
|
|
|
|
if (!credU) goto exit;
|
|
|
|
|
|
|
|
pwd.bv_len = strlen( credU );
|
|
|
|
pwd.bv_val = credU;
|
|
|
|
}
|
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_sasl_bind_s( ld->ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL ));
|
2005-07-26 12:30:49 +02:00
|
|
|
}
|
2020-03-23 14:14:15 +01:00
|
|
|
else if (method == WLDAP32_LDAP_AUTH_NEGOTIATE)
|
|
|
|
{
|
|
|
|
SEC_WINNT_AUTH_IDENTITY_A idU;
|
|
|
|
SEC_WINNT_AUTH_IDENTITY_W idW;
|
|
|
|
SEC_WINNT_AUTH_IDENTITY_W *id = (SEC_WINNT_AUTH_IDENTITY_W *)cred;
|
|
|
|
|
|
|
|
memset( &idU, 0, sizeof(idU) );
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
if (id->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
|
|
|
|
{
|
|
|
|
idW.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
|
|
|
idW.Domain = (unsigned short *)strnAtoW( (char *)id->Domain, id->DomainLength, &idW.DomainLength );
|
|
|
|
idW.User = (unsigned short *)strnAtoW( (char *)id->User, id->UserLength, &idW.UserLength );
|
|
|
|
idW.Password = (unsigned short *)strnAtoW( (char *)id->Password, id->PasswordLength, &idW.PasswordLength );
|
|
|
|
|
|
|
|
id = &idW;
|
|
|
|
}
|
|
|
|
|
|
|
|
idU.Domain = (unsigned char *)strnWtoU( id->Domain, id->DomainLength, &idU.DomainLength );
|
|
|
|
idU.User = (unsigned char *)strnWtoU( id->User, id->UserLength, &idU.UserLength );
|
|
|
|
idU.Password = (unsigned char *)strnWtoU( id->Password, id->PasswordLength, &idU.PasswordLength );
|
|
|
|
}
|
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_sasl_interactive_bind_s( ld->ld,
|
2020-03-23 14:14:15 +01:00
|
|
|
NULL /* server will ignore DN anyway */,
|
|
|
|
NULL /* query supportedSASLMechanisms */,
|
|
|
|
NULL, NULL, LDAP_SASL_QUIET, sasl_interact, &idU ));
|
|
|
|
|
|
|
|
if (id && (id->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI))
|
|
|
|
{
|
|
|
|
strfreeW( (WCHAR *)idW.Domain );
|
|
|
|
strfreeW( (WCHAR *)idW.User );
|
|
|
|
strfreeW( (WCHAR *)idW.Password );
|
|
|
|
}
|
|
|
|
|
|
|
|
strfreeU( (char *)idU.Domain );
|
|
|
|
strfreeU( (char *)idU.User );
|
|
|
|
strfreeU( (char *)idU.Password );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME( "method %#x not supported\n", method );
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-26 12:30:49 +02:00
|
|
|
}
|
2005-07-19 22:32:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-19 22:32:46 +02:00
|
|
|
strfreeU( dnU );
|
|
|
|
strfreeU( credU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_sasl_bindA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_sasl_bindW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_sasl_bindA( WLDAP32_LDAP *ld, const PCHAR dn,
|
2005-07-24 19:10:46 +02:00
|
|
|
const PCHAR mechanism, const BERVAL *cred, PLDAPControlA *serverctrls,
|
|
|
|
PLDAPControlA *clientctrls, int *message )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-24 19:10:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
WCHAR *dnW, *mechanismW = NULL;
|
|
|
|
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
|
|
|
|
debugstr_a(mechanism), cred, serverctrls, clientctrls, message );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld || !dn || !mechanism || !cred || !message)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
2005-07-24 19:10:46 +02:00
|
|
|
dnW = strAtoW( dn );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!dnW) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
mechanismW = strAtoW( mechanism );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!mechanismW) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsW = controlarrayAtoW( serverctrls );
|
|
|
|
if (!serverctrlsW) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsW = controlarrayAtoW( clientctrls );
|
|
|
|
if (!clientctrlsW) goto exit;
|
|
|
|
}
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
ret = ldap_sasl_bindW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, message );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-24 19:10:46 +02:00
|
|
|
strfreeW( dnW );
|
|
|
|
strfreeW( mechanismW );
|
|
|
|
controlarrayfreeW( serverctrlsW );
|
|
|
|
controlarrayfreeW( clientctrlsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_sasl_bindW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Authenticate with an LDAP server using SASL (asynchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of entry to bind as.
|
|
|
|
* mechanism [I] Authentication method.
|
|
|
|
* cred [I] Credentials.
|
|
|
|
* serverctrls [I] Array of LDAP server controls.
|
|
|
|
* clientctrls [I] Array of LDAP client controls.
|
|
|
|
* message [O] Message ID of the bind operation.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The serverctrls and clientctrls parameters are optional and should
|
|
|
|
* be set to NULL if not used.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_sasl_bindW( WLDAP32_LDAP *ld, const PWCHAR dn,
|
2005-07-24 19:10:46 +02:00
|
|
|
const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls,
|
|
|
|
PLDAPControlW *clientctrls, int *message )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-24 19:10:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
char *dnU, *mechanismU = NULL;
|
|
|
|
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
|
2006-10-05 15:37:39 +02:00
|
|
|
struct berval credU;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
|
|
|
|
debugstr_w(mechanism), cred, serverctrls, clientctrls, message );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld || !dn || !mechanism || !cred || !message)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
2005-07-24 19:10:46 +02:00
|
|
|
dnU = strWtoU( dn );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!dnU) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
mechanismU = strWtoU( mechanism );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!mechanismU) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsU = controlarrayWtoU( serverctrls );
|
|
|
|
if (!serverctrlsU) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsU = controlarrayWtoU( clientctrls );
|
|
|
|
if (!clientctrlsU) goto exit;
|
|
|
|
}
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2006-10-05 15:37:39 +02:00
|
|
|
credU.bv_len = cred->bv_len;
|
|
|
|
credU.bv_val = cred->bv_val;
|
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_sasl_bind( ld->ld, dnU, mechanismU, &credU,
|
2008-10-20 12:22:13 +02:00
|
|
|
serverctrlsU, clientctrlsU, message ));
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-24 19:10:46 +02:00
|
|
|
strfreeU( dnU );
|
|
|
|
strfreeU( mechanismU );
|
|
|
|
controlarrayfreeU( serverctrlsU );
|
|
|
|
controlarrayfreeU( clientctrlsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_sasl_bind_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_sasl_bind_sW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_sasl_bind_sA( WLDAP32_LDAP *ld, const PCHAR dn,
|
2005-07-24 19:10:46 +02:00
|
|
|
const PCHAR mechanism, const BERVAL *cred, PLDAPControlA *serverctrls,
|
|
|
|
PLDAPControlA *clientctrls, PBERVAL *serverdata )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-24 19:10:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
WCHAR *dnW, *mechanismW = NULL;
|
|
|
|
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
|
|
|
|
debugstr_a(mechanism), cred, serverctrls, clientctrls, serverdata );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld || !dn || !mechanism || !cred || !serverdata)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
2005-07-24 19:10:46 +02:00
|
|
|
dnW = strAtoW( dn );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!dnW) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
mechanismW = strAtoW( mechanism );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!mechanismW) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsW = controlarrayAtoW( serverctrls );
|
|
|
|
if (!serverctrlsW) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsW = controlarrayAtoW( clientctrls );
|
|
|
|
if (!clientctrlsW) goto exit;
|
|
|
|
}
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
ret = ldap_sasl_bind_sW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, serverdata );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-24 19:10:46 +02:00
|
|
|
strfreeW( dnW );
|
|
|
|
strfreeW( mechanismW );
|
|
|
|
controlarrayfreeW( serverctrlsW );
|
|
|
|
controlarrayfreeW( clientctrlsW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_sasl_bind_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Authenticate with an LDAP server using SASL (synchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of entry to bind as.
|
|
|
|
* mechanism [I] Authentication method.
|
|
|
|
* cred [I] Credentials.
|
|
|
|
* serverctrls [I] Array of LDAP server controls.
|
|
|
|
* clientctrls [I] Array of LDAP client controls.
|
|
|
|
* serverdata [O] Authentication response from the server.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The serverctrls and clientctrls parameters are optional and should
|
|
|
|
* be set to NULL if not used.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_sasl_bind_sW( WLDAP32_LDAP *ld, const PWCHAR dn,
|
2005-07-24 19:10:46 +02:00
|
|
|
const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls,
|
|
|
|
PLDAPControlW *clientctrls, PBERVAL *serverdata )
|
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-24 19:10:46 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
char *dnU, *mechanismU = NULL;
|
|
|
|
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
|
2006-10-05 15:37:39 +02:00
|
|
|
struct berval credU;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
|
|
|
|
debugstr_w(mechanism), cred, serverctrls, clientctrls, serverdata );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld || !dn || !mechanism || !cred || !serverdata)
|
|
|
|
return WLDAP32_LDAP_PARAM_ERROR;
|
|
|
|
|
2005-07-24 19:10:46 +02:00
|
|
|
dnU = strWtoU( dn );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!dnU) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
|
|
|
mechanismU = strWtoU( mechanism );
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!mechanismU) goto exit;
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (serverctrls) {
|
|
|
|
serverctrlsU = controlarrayWtoU( serverctrls );
|
|
|
|
if (!serverctrlsU) goto exit;
|
|
|
|
}
|
|
|
|
if (clientctrls) {
|
|
|
|
clientctrlsU = controlarrayWtoU( clientctrls );
|
|
|
|
if (!clientctrlsU) goto exit;
|
|
|
|
}
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2006-10-05 15:37:39 +02:00
|
|
|
credU.bv_len = cred->bv_len;
|
|
|
|
credU.bv_val = cred->bv_val;
|
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_sasl_bind_s( ld->ld, dnU, mechanismU, &credU,
|
2008-10-20 12:22:13 +02:00
|
|
|
serverctrlsU, clientctrlsU, (struct berval **)serverdata ));
|
2005-07-24 19:10:46 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-24 19:10:46 +02:00
|
|
|
strfreeU( dnU );
|
|
|
|
strfreeU( mechanismU );
|
|
|
|
controlarrayfreeU( serverctrlsU );
|
|
|
|
controlarrayfreeU( clientctrlsU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_simple_bindA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_simple_bindW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_simple_bindA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR passwd )
|
2005-07-20 19:47:53 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-20 19:47:53 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
WCHAR *dnW = NULL, *passwdW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), passwd );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnW = strAtoW( dn );
|
|
|
|
if (!dnW) goto exit;
|
|
|
|
}
|
|
|
|
if (passwd) {
|
|
|
|
passwdW = strAtoW( passwd );
|
|
|
|
if (!passwdW) goto exit;
|
|
|
|
}
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
ret = ldap_simple_bindW( ld, dnW, passwdW );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-20 19:47:53 +02:00
|
|
|
strfreeW( dnW );
|
|
|
|
strfreeW( passwdW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_simple_bindW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Authenticate with an LDAP server (asynchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of entry to bind as.
|
|
|
|
* passwd [I] Password string.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Message ID of the bind operation.
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Set dn and passwd to NULL to bind as an anonymous user.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_simple_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
|
2005-07-20 19:47:53 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-20 19:47:53 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
char *dnU = NULL, *passwdU = NULL;
|
2005-11-18 16:05:01 +01:00
|
|
|
struct berval pwd = { 0, NULL };
|
|
|
|
int msg;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), passwd );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld) return ~0u;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnU = strWtoU( dn );
|
|
|
|
if (!dnU) goto exit;
|
|
|
|
}
|
|
|
|
if (passwd) {
|
|
|
|
passwdU = strWtoU( passwd );
|
|
|
|
if (!passwdU) goto exit;
|
2005-11-18 16:05:01 +01:00
|
|
|
|
|
|
|
pwd.bv_len = strlen( passwdU );
|
|
|
|
pwd.bv_val = passwdU;
|
2005-07-26 12:30:49 +02:00
|
|
|
}
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = ldap_sasl_bind( ld->ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );
|
2005-11-18 16:05:01 +01:00
|
|
|
|
|
|
|
if (ret == LDAP_SUCCESS)
|
|
|
|
ret = msg;
|
|
|
|
else
|
2009-01-05 12:40:28 +01:00
|
|
|
ret = ~0u;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-20 19:47:53 +02:00
|
|
|
strfreeU( dnU );
|
|
|
|
strfreeU( passwdU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_simple_bind_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_simple_bind_sW.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_simple_bind_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR passwd )
|
2005-07-20 19:47:53 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-20 19:47:53 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
WCHAR *dnW = NULL, *passwdW = NULL;
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), passwd );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnW = strAtoW( dn );
|
|
|
|
if (!dnW) goto exit;
|
|
|
|
}
|
|
|
|
if (passwd) {
|
|
|
|
passwdW = strAtoW( passwd );
|
|
|
|
if (!passwdW) goto exit;
|
|
|
|
}
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
ret = ldap_simple_bind_sW( ld, dnW, passwdW );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-20 19:47:53 +02:00
|
|
|
strfreeW( dnW );
|
|
|
|
strfreeW( passwdW );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_simple_bind_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Authenticate with an LDAP server (synchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of entry to bind as.
|
|
|
|
* passwd [I] Password string.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Set dn and passwd to NULL to bind as an anonymous user.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL ldap_simple_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
|
2005-07-20 19:47:53 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-20 19:47:53 +02:00
|
|
|
#ifdef HAVE_LDAP
|
2005-07-26 12:30:49 +02:00
|
|
|
char *dnU = NULL, *passwdU = NULL;
|
2005-11-18 16:05:01 +01:00
|
|
|
struct berval pwd = { 0, NULL };
|
2005-08-02 16:42:10 +02:00
|
|
|
|
|
|
|
ret = WLDAP32_LDAP_NO_MEMORY;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), passwd );
|
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
if (dn) {
|
|
|
|
dnU = strWtoU( dn );
|
|
|
|
if (!dnU) goto exit;
|
|
|
|
}
|
|
|
|
if (passwd) {
|
|
|
|
passwdU = strWtoU( passwd );
|
|
|
|
if (!passwdU) goto exit;
|
2005-11-18 16:05:01 +01:00
|
|
|
|
|
|
|
pwd.bv_len = strlen( passwdU );
|
|
|
|
pwd.bv_val = passwdU;
|
2005-07-26 12:30:49 +02:00
|
|
|
}
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2020-04-03 10:56:57 +02:00
|
|
|
ret = map_error( ldap_sasl_bind_s( ld->ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL ));
|
2005-07-20 19:47:53 +02:00
|
|
|
|
2005-07-26 12:30:49 +02:00
|
|
|
exit:
|
2005-07-20 19:47:53 +02:00
|
|
|
strfreeU( dnU );
|
|
|
|
strfreeU( passwdU );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_unbind (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Close LDAP connection and free resources (asynchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL WLDAP32_ldap_unbind( WLDAP32_LDAP *ld )
|
2005-07-20 19:47:53 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-20 19:47:53 +02:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
|
|
|
|
TRACE( "(%p)\n", ld );
|
2005-07-26 12:30:49 +02:00
|
|
|
|
|
|
|
if (ld)
|
2020-04-03 10:56:57 +02:00
|
|
|
{
|
|
|
|
ret = map_error( ldap_unbind_ext( ld->ld, NULL, NULL ));
|
2020-04-03 10:57:03 +02:00
|
|
|
if ( ld->ld_server_ctrls )
|
|
|
|
ldap_value_free_len( ld->ld_server_ctrls );
|
2020-04-03 10:56:57 +02:00
|
|
|
heap_free( ld );
|
|
|
|
}
|
2005-07-26 12:30:49 +02:00
|
|
|
else
|
|
|
|
ret = WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-28 20:41:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_unbind_s (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Close LDAP connection and free resources (synchronous operation).
|
|
|
|
*
|
2005-12-02 11:26:19 +01:00
|
|
|
* PARAMS
|
2005-11-28 20:41:08 +01:00
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2006-06-12 21:34:46 +02:00
|
|
|
ULONG CDECL WLDAP32_ldap_unbind_s( WLDAP32_LDAP *ld )
|
2005-07-20 19:47:53 +02:00
|
|
|
{
|
2007-11-08 13:11:34 +01:00
|
|
|
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
2005-07-20 19:47:53 +02:00
|
|
|
#ifdef HAVE_LDAP
|
|
|
|
|
|
|
|
TRACE( "(%p)\n", ld );
|
2005-07-26 12:30:49 +02:00
|
|
|
|
|
|
|
if (ld)
|
2020-04-03 10:56:57 +02:00
|
|
|
{
|
|
|
|
ret = map_error( ldap_unbind_ext_s( ld->ld, NULL, NULL ));
|
2020-04-03 10:57:03 +02:00
|
|
|
if ( ld->ld_server_ctrls )
|
|
|
|
ldap_value_free_len( ld->ld_server_ctrls );
|
2020-04-03 10:56:57 +02:00
|
|
|
heap_free( ld );
|
|
|
|
}
|
2005-07-26 12:30:49 +02:00
|
|
|
else
|
|
|
|
ret = WLDAP32_LDAP_PARAM_ERROR;
|
2005-07-20 19:47:53 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|