bind.c 17.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * 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
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20 21 22 23 24 25 26 27 28 29 30 31
 */

#include "config.h"

#include "wine/port.h"
#include "wine/debug.h"

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "winnls.h"

32
#ifdef HAVE_LDAP_H
33 34 35 36 37 38 39 40 41 42 43
#include <ldap.h>
#else
#define LDAP_SUCCESS        0x00
#define LDAP_NOT_SUPPORTED  0x5c
#endif

#include "winldap_private.h"
#include "wldap32.h"

WINE_DEFAULT_DEBUG_CHANNEL(wldap32);

44 45 46 47 48
/***********************************************************************
 *      ldap_bindA     (WLDAP32.@)
 *
 * See ldap_bindW.
 */
49
ULONG CDECL ldap_bindA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR cred, ULONG method )
50 51 52
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
53
    WCHAR *dnW = NULL, *credW = NULL;
54 55

    ret = WLDAP32_LDAP_NO_MEMORY;
56

57
    TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), cred, method );
58

59
    if (!ld) return ~0UL;
60

61 62 63 64 65 66 67 68
    if (dn) {
        dnW = strAtoW( dn );
        if (!dnW) goto exit;
    }
    if (cred) {
        credW = strAtoW( cred );
        if (!credW) goto exit;
    }
69 70 71

    ret = ldap_bindW( ld, dnW, credW, method );

72
exit:
73 74 75 76 77 78 79
    strfreeW( dnW );
    strfreeW( credW );

#endif
    return ret;
}

80 81 82 83 84
/***********************************************************************
 *      ldap_bindW     (WLDAP32.@)
 *
 * Authenticate with an LDAP server (asynchronous operation).
 *
85
 * PARAMS
86 87 88 89 90 91 92 93 94 95
 *  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
96
 *  Only LDAP_AUTH_SIMPLE is supported (just like native).
97
 */
98
ULONG CDECL ldap_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
99 100 101
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
102
    char *dnU = NULL, *credU = NULL;
103 104
    struct berval pwd = { 0, NULL };
    int msg;
105 106

    ret = WLDAP32_LDAP_NO_MEMORY;
107

108
    TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), cred, method );
109

110
    if (!ld) return ~0UL;
111
    if (method != LDAP_AUTH_SIMPLE) return WLDAP32_LDAP_PARAM_ERROR;
112

113 114 115 116 117 118 119
    if (dn) {
        dnU = strWtoU( dn );
        if (!dnU) goto exit;
    }
    if (cred) {
        credU = strWtoU( cred );
        if (!credU) goto exit;
120 121 122

        pwd.bv_len = strlen( credU );
        pwd.bv_val = credU;
123
    }
124

125 126 127 128 129 130
    ret = ldap_sasl_bind( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );

    if (ret == LDAP_SUCCESS)
        ret = msg;
    else
        ret = ~0UL;
131

132
exit:
133 134 135 136 137 138 139
    strfreeU( dnU );
    strfreeU( credU );

#endif
    return ret;
}

140 141 142 143 144
/***********************************************************************
 *      ldap_bind_sA     (WLDAP32.@)
 *
 * See ldap_bind_sW.
 */
145
ULONG CDECL ldap_bind_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR cred, ULONG method )
146 147 148
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
149
    WCHAR *dnW = NULL, *credW = NULL;
150 151

    ret = WLDAP32_LDAP_NO_MEMORY;
152

153
    TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), cred, method );
154

155
    if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
156

157 158 159 160 161 162 163 164
    if (dn) {
        dnW = strAtoW( dn );
        if (!dnW) goto exit;
    }
    if (cred) {
        credW = strAtoW( cred );
        if (!credW) goto exit;
    }
165 166 167

    ret = ldap_bind_sW( ld, dnW, credW, method );

168
exit:
169 170 171 172 173 174 175
    strfreeW( dnW );
    strfreeW( credW );

#endif
    return ret;
}

176 177 178 179 180
/***********************************************************************
 *      ldap_bind_sW     (WLDAP32.@)
 *
 * Authenticate with an LDAP server (synchronous operation).
 *
181
 * PARAMS
182 183 184 185 186 187 188 189 190
 *  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.
 */
191
ULONG CDECL ldap_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
192 193 194
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
195
    char *dnU = NULL, *credU = NULL;
196
    struct berval pwd = { 0, NULL };
197 198

    ret = WLDAP32_LDAP_NO_MEMORY;
199

200
    TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), cred, method );
201

202
    if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
203
    if (method != LDAP_AUTH_SIMPLE) return WLDAP32_LDAP_PARAM_ERROR;
204

205 206 207 208 209 210 211
    if (dn) {
        dnU = strWtoU( dn );
        if (!dnU) goto exit;
    }
    if (cred) {
        credU = strWtoU( cred );
        if (!credU) goto exit;
212 213 214

        pwd.bv_len = strlen( credU );
        pwd.bv_val = credU;
215
    }
216

217
    ret = ldap_sasl_bind_s( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL );
218

219
exit:
220 221 222 223 224 225
    strfreeU( dnU );
    strfreeU( credU );

#endif
    return ret;
}
226

227 228 229 230 231
/***********************************************************************
 *      ldap_sasl_bindA     (WLDAP32.@)
 *
 * See ldap_sasl_bindW.
 */
232
ULONG CDECL ldap_sasl_bindA( WLDAP32_LDAP *ld, const PCHAR dn,
233 234 235 236 237
    const PCHAR mechanism, const BERVAL *cred, PLDAPControlA *serverctrls,
    PLDAPControlA *clientctrls, int *message )
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
238 239
    WCHAR *dnW, *mechanismW = NULL;
    LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
240 241

    ret = WLDAP32_LDAP_NO_MEMORY;
242 243 244 245

    TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
           debugstr_a(mechanism), cred, serverctrls, clientctrls, message );

246 247 248
    if (!ld || !dn || !mechanism || !cred || !message)
        return WLDAP32_LDAP_PARAM_ERROR;

249
    dnW = strAtoW( dn );
250
    if (!dnW) goto exit;
251 252

    mechanismW = strAtoW( mechanism );
253
    if (!mechanismW) goto exit;
254

255 256 257 258 259 260 261 262
    if (serverctrls) {
        serverctrlsW = controlarrayAtoW( serverctrls );
        if (!serverctrlsW) goto exit;
    }
    if (clientctrls) {
        clientctrlsW = controlarrayAtoW( clientctrls );
        if (!clientctrlsW) goto exit;
    }
263 264 265

    ret = ldap_sasl_bindW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, message );

266
exit:
267 268 269 270 271 272 273 274 275
    strfreeW( dnW );
    strfreeW( mechanismW );
    controlarrayfreeW( serverctrlsW );
    controlarrayfreeW( clientctrlsW );

#endif
    return ret;
}

276 277 278 279 280
/***********************************************************************
 *      ldap_sasl_bindW     (WLDAP32.@)
 *
 * Authenticate with an LDAP server using SASL (asynchronous operation).
 *
281
 * PARAMS
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
 *  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.
 */
298
ULONG CDECL ldap_sasl_bindW( WLDAP32_LDAP *ld, const PWCHAR dn,
299 300 301 302 303
    const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls,
    PLDAPControlW *clientctrls, int *message )
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
304 305
    char *dnU, *mechanismU = NULL;
    LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
306
    struct berval credU;
307 308

    ret = WLDAP32_LDAP_NO_MEMORY;
309 310 311 312

    TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
           debugstr_w(mechanism), cred, serverctrls, clientctrls, message );

313 314 315
    if (!ld || !dn || !mechanism || !cred || !message)
        return WLDAP32_LDAP_PARAM_ERROR;

316
    dnU = strWtoU( dn );
317
    if (!dnU) goto exit;
318 319

    mechanismU = strWtoU( mechanism );
320
    if (!mechanismU) goto exit;
321

322 323 324 325 326 327 328 329
    if (serverctrls) {
        serverctrlsU = controlarrayWtoU( serverctrls );
        if (!serverctrlsU) goto exit;
    }
    if (clientctrls) {
        clientctrlsU = controlarrayWtoU( clientctrls );
        if (!clientctrlsU) goto exit;
    }
330

331 332 333 334
    credU.bv_len = cred->bv_len;
    credU.bv_val = cred->bv_val;

    ret = ldap_sasl_bind( ld, dnU, mechanismU, &credU,
335 336
                          serverctrlsU, clientctrlsU, message );

337
exit:
338 339 340 341 342 343 344 345 346
    strfreeU( dnU );
    strfreeU( mechanismU );
    controlarrayfreeU( serverctrlsU );
    controlarrayfreeU( clientctrlsU );

#endif
    return ret;
}

347 348 349 350 351
/***********************************************************************
 *      ldap_sasl_bind_sA     (WLDAP32.@)
 *
 * See ldap_sasl_bind_sW.
 */
352
ULONG CDECL ldap_sasl_bind_sA( WLDAP32_LDAP *ld, const PCHAR dn,
353 354 355 356 357
    const PCHAR mechanism, const BERVAL *cred, PLDAPControlA *serverctrls,
    PLDAPControlA *clientctrls, PBERVAL *serverdata )
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
358 359
    WCHAR *dnW, *mechanismW = NULL;
    LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
360 361

    ret = WLDAP32_LDAP_NO_MEMORY;
362 363 364 365

    TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
           debugstr_a(mechanism), cred, serverctrls, clientctrls, serverdata );

366 367 368
    if (!ld || !dn || !mechanism || !cred || !serverdata)
        return WLDAP32_LDAP_PARAM_ERROR;

369
    dnW = strAtoW( dn );
370
    if (!dnW) goto exit;
371 372

    mechanismW = strAtoW( mechanism );
373
    if (!mechanismW) goto exit;
374

375 376 377 378 379 380 381 382
    if (serverctrls) {
        serverctrlsW = controlarrayAtoW( serverctrls );
        if (!serverctrlsW) goto exit;
    }
    if (clientctrls) {
        clientctrlsW = controlarrayAtoW( clientctrls );
        if (!clientctrlsW) goto exit;
    }
383 384 385

    ret = ldap_sasl_bind_sW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, serverdata );

386
exit:
387 388 389 390 391 392 393 394 395
    strfreeW( dnW );
    strfreeW( mechanismW );
    controlarrayfreeW( serverctrlsW );
    controlarrayfreeW( clientctrlsW );

#endif
    return ret;
}

396 397 398 399 400
/***********************************************************************
 *      ldap_sasl_bind_sW     (WLDAP32.@)
 *
 * Authenticate with an LDAP server using SASL (synchronous operation).
 *
401
 * PARAMS
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
 *  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.
 */
418
ULONG CDECL ldap_sasl_bind_sW( WLDAP32_LDAP *ld, const PWCHAR dn,
419 420 421 422 423
    const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls,
    PLDAPControlW *clientctrls, PBERVAL *serverdata )
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
424 425
    char *dnU, *mechanismU = NULL;
    LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
426
    struct berval credU;
427 428

    ret = WLDAP32_LDAP_NO_MEMORY;
429 430 431 432

    TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
           debugstr_w(mechanism), cred, serverctrls, clientctrls, serverdata );

433 434 435
    if (!ld || !dn || !mechanism || !cred || !serverdata)
        return WLDAP32_LDAP_PARAM_ERROR;

436
    dnU = strWtoU( dn );
437
    if (!dnU) goto exit;
438 439

    mechanismU = strWtoU( mechanism );
440
    if (!mechanismU) goto exit;
441

442 443 444 445 446 447 448 449
    if (serverctrls) {
        serverctrlsU = controlarrayWtoU( serverctrls );
        if (!serverctrlsU) goto exit;
    }
    if (clientctrls) {
        clientctrlsU = controlarrayWtoU( clientctrls );
        if (!clientctrlsU) goto exit;
    }
450

451 452 453 454
    credU.bv_len = cred->bv_len;
    credU.bv_val = cred->bv_val;

    ret = ldap_sasl_bind_s( ld, dnU, mechanismU, &credU,
455 456
                            serverctrlsU, clientctrlsU, (struct berval **)serverdata );

457
exit:
458 459 460 461 462 463 464 465 466
    strfreeU( dnU );
    strfreeU( mechanismU );
    controlarrayfreeU( serverctrlsU );
    controlarrayfreeU( clientctrlsU );

#endif
    return ret;
}

467 468 469 470 471
/***********************************************************************
 *      ldap_simple_bindA     (WLDAP32.@)
 *
 * See ldap_simple_bindW.
 */
472
ULONG CDECL ldap_simple_bindA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR passwd )
473 474 475
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
476
    WCHAR *dnW = NULL, *passwdW = NULL;
477 478

    ret = WLDAP32_LDAP_NO_MEMORY;
479 480 481

    TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), passwd );

482
    if (!ld) return ~0UL;
483

484 485 486 487 488 489 490 491
    if (dn) {
        dnW = strAtoW( dn );
        if (!dnW) goto exit;
    }
    if (passwd) {
        passwdW = strAtoW( passwd );
        if (!passwdW) goto exit;
    }
492 493 494

    ret = ldap_simple_bindW( ld, dnW, passwdW );

495
exit:
496 497 498 499 500 501 502
    strfreeW( dnW );
    strfreeW( passwdW );

#endif
    return ret;
}

503 504 505 506 507
/***********************************************************************
 *      ldap_simple_bindW     (WLDAP32.@)
 *
 * Authenticate with an LDAP server (asynchronous operation).
 *
508
 * PARAMS
509 510 511 512 513 514 515 516 517 518 519
 *  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. 
 */
520
ULONG CDECL ldap_simple_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
521 522 523
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
524
    char *dnU = NULL, *passwdU = NULL;
525 526
    struct berval pwd = { 0, NULL };
    int msg;
527 528

    ret = WLDAP32_LDAP_NO_MEMORY;
529 530 531

    TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), passwd );

532
    if (!ld) return ~0UL;
533

534 535 536 537 538 539 540
    if (dn) {
        dnU = strWtoU( dn );
        if (!dnU) goto exit;
    }
    if (passwd) {
        passwdU = strWtoU( passwd );
        if (!passwdU) goto exit;
541 542 543

        pwd.bv_len = strlen( passwdU );
        pwd.bv_val = passwdU;
544
    }
545

546 547 548 549 550 551
    ret = ldap_sasl_bind( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );

    if (ret == LDAP_SUCCESS)
        ret = msg;
    else
        ret = ~0UL;
552

553
exit:
554 555 556 557 558 559 560
    strfreeU( dnU );
    strfreeU( passwdU );

#endif
    return ret;
}

561 562 563 564 565
/***********************************************************************
 *      ldap_simple_bind_sA     (WLDAP32.@)
 *
 * See ldap_simple_bind_sW.
 */
566
ULONG CDECL ldap_simple_bind_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR passwd )
567 568 569
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
570
    WCHAR *dnW = NULL, *passwdW = NULL;
571 572

    ret = WLDAP32_LDAP_NO_MEMORY;
573 574 575

    TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), passwd );

576
    if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
577

578 579 580 581 582 583 584 585
    if (dn) {
        dnW = strAtoW( dn );
        if (!dnW) goto exit;
    }
    if (passwd) {
        passwdW = strAtoW( passwd );
        if (!passwdW) goto exit;
    }
586 587 588

    ret = ldap_simple_bind_sW( ld, dnW, passwdW );

589
exit:
590 591 592 593 594 595 596
    strfreeW( dnW );
    strfreeW( passwdW );

#endif
    return ret;
}

597 598 599 600 601
/***********************************************************************
 *      ldap_simple_bind_sW     (WLDAP32.@)
 *
 * Authenticate with an LDAP server (synchronous operation).
 *
602
 * PARAMS
603 604 605 606 607 608 609 610 611 612 613
 *  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. 
 */
614
ULONG CDECL ldap_simple_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
615 616 617
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
618
    char *dnU = NULL, *passwdU = NULL;
619
    struct berval pwd = { 0, NULL };
620 621

    ret = WLDAP32_LDAP_NO_MEMORY;
622 623 624

    TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), passwd );

625
    if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
626

627 628 629 630 631 632 633
    if (dn) {
        dnU = strWtoU( dn );
        if (!dnU) goto exit;
    }
    if (passwd) {
        passwdU = strWtoU( passwd );
        if (!passwdU) goto exit;
634 635 636

        pwd.bv_len = strlen( passwdU );
        pwd.bv_val = passwdU;
637
    }
638

639
    ret = ldap_sasl_bind_s( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL );
640

641
exit:
642 643 644 645 646 647 648
    strfreeU( dnU );
    strfreeU( passwdU );

#endif
    return ret;
}

649 650 651 652 653
/***********************************************************************
 *      ldap_unbind     (WLDAP32.@)
 *
 * Close LDAP connection and free resources (asynchronous operation).
 *
654
 * PARAMS
655 656 657 658 659 660
 *  ld  [I] Pointer to an LDAP context.
 *
 * RETURNS
 *  Success: LDAP_SUCCESS
 *  Failure: An LDAP error code.
 */
661
ULONG CDECL WLDAP32_ldap_unbind( WLDAP32_LDAP *ld )
662 663 664 665 666
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP

    TRACE( "(%p)\n", ld );
667 668

    if (ld)
669
        ret = ldap_unbind_ext( ld, NULL, NULL );
670 671
    else
        ret = WLDAP32_LDAP_PARAM_ERROR;
672 673 674 675 676

#endif
    return ret;
}

677 678 679 680 681
/***********************************************************************
 *      ldap_unbind_s     (WLDAP32.@)
 *
 * Close LDAP connection and free resources (synchronous operation).
 *
682
 * PARAMS
683 684 685 686 687 688
 *  ld  [I] Pointer to an LDAP context.
 *
 * RETURNS
 *  Success: LDAP_SUCCESS
 *  Failure: An LDAP error code.
 */
689
ULONG CDECL WLDAP32_ldap_unbind_s( WLDAP32_LDAP *ld )
690 691 692 693 694
{
    ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP

    TRACE( "(%p)\n", ld );
695 696

    if (ld)
697
        ret = ldap_unbind_ext_s( ld, NULL, NULL );
698 699
    else
        ret = WLDAP32_LDAP_PARAM_ERROR;
700 701 702 703

#endif
    return ret;
}