ReactOS 0.4.15-dev-7906-g1b85a5f
bind.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h"
Include dependency graph for bind.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wldap32)
 
ULONG CDECL ldap_bindA (WLDAP32_LDAP *ld, PCHAR dn, PCHAR cred, ULONG method)
 
ULONG CDECL ldap_bindW (WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method)
 
ULONG CDECL ldap_bind_sA (WLDAP32_LDAP *ld, PCHAR dn, PCHAR cred, ULONG method)
 
ULONG CDECL ldap_bind_sW (WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method)
 
ULONG CDECL ldap_sasl_bindA (WLDAP32_LDAP *ld, const PCHAR dn, const PCHAR mechanism, const BERVAL *cred, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, int *message)
 
ULONG CDECL ldap_sasl_bindW (WLDAP32_LDAP *ld, const PWCHAR dn, const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, int *message)
 
ULONG CDECL ldap_sasl_bind_sA (WLDAP32_LDAP *ld, const PCHAR dn, const PCHAR mechanism, const BERVAL *cred, PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PBERVAL *serverdata)
 
ULONG CDECL ldap_sasl_bind_sW (WLDAP32_LDAP *ld, const PWCHAR dn, const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PBERVAL *serverdata)
 
ULONG CDECL ldap_simple_bindA (WLDAP32_LDAP *ld, PCHAR dn, PCHAR passwd)
 
ULONG CDECL ldap_simple_bindW (WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd)
 
ULONG CDECL ldap_simple_bind_sA (WLDAP32_LDAP *ld, PCHAR dn, PCHAR passwd)
 
ULONG CDECL ldap_simple_bind_sW (WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd)
 
ULONG CDECL WLDAP32_ldap_unbind (WLDAP32_LDAP *ld)
 
ULONG CDECL WLDAP32_ldap_unbind_s (WLDAP32_LDAP *ld)
 

Function Documentation

◆ ldap_bind_sA()

ULONG CDECL ldap_bind_sA ( WLDAP32_LDAP ld,
PCHAR  dn,
PCHAR  cred,
ULONG  method 
)

Definition at line 140 of file bind.c.

141{
143#ifdef HAVE_LDAP
144 WCHAR *dnW = NULL, *credW = NULL;
145
147
148 TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), cred, method );
149
150 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
151
152 if (dn) {
153 dnW = strAtoW( dn );
154 if (!dnW) goto exit;
155 }
156 if (cred) {
157 credW = strAtoW( cred );
158 if (!credW) goto exit;
159 }
160
161 ret = ldap_bind_sW( ld, dnW, credW, method );
162
163exit:
164 strfreeW( dnW );
165 strfreeW( credW );
166
167#endif
168 return ret;
169}
#define NULL
Definition: types.h:112
ULONG CDECL ldap_bind_sW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method)
Definition: bind.c:186
method
Definition: dragdrop.c:54
static LPWSTR strAtoW(const char *str)
#define debugstr_a
Definition: kernel32.h:31
#define exit(n)
Definition: config.h:202
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t ULONG
Definition: typedefs.h:59
int ret
@ WLDAP32_LDAP_PARAM_ERROR
@ WLDAP32_LDAP_NOT_SUPPORTED
@ WLDAP32_LDAP_NO_MEMORY
static void strfreeW(LPWSTR str)
Definition: wldap32.h:103
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ldap_bind_sW()

ULONG CDECL ldap_bind_sW ( WLDAP32_LDAP ld,
PWCHAR  dn,
PWCHAR  cred,
ULONG  method 
)

Definition at line 186 of file bind.c.

187{
189#ifdef HAVE_LDAP
190 char *dnU = NULL, *credU = NULL;
191 struct berval pwd = { 0, NULL };
192
194
195 TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), cred, method );
196
197 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
199
200 if (dn) {
201 dnU = strWtoU( dn );
202 if (!dnU) goto exit;
203 }
204 if (cred) {
205 credU = strWtoU( cred );
206 if (!credU) goto exit;
207
208 pwd.bv_len = strlen( credU );
209 pwd.bv_val = credU;
210 }
211
212 ret = map_error( ldap_sasl_bind_s( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL ));
213
214exit:
215 strfreeU( dnU );
216 strfreeU( credU );
217
218#endif
219 return ret;
220}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void pwd(int argc, const char *argv[])
Definition: cmds.c:1401
static UINT map_error(DWORD error)
Definition: service.c:35
#define debugstr_w
Definition: kernel32.h:32
Definition: winber.h:32
#define ldap_sasl_bind_s
Definition: winldap.h:637
#define LDAP_AUTH_SIMPLE
Definition: winldap.h:224
static void strfreeU(char *str)
Definition: wldap32.h:108
static char * strWtoU(LPCWSTR str)
Definition: wldap32.h:74

Referenced by ldap_bind_sA().

◆ ldap_bindA()

ULONG CDECL ldap_bindA ( WLDAP32_LDAP ld,
PCHAR  dn,
PCHAR  cred,
ULONG  method 
)

Definition at line 44 of file bind.c.

45{
47#ifdef HAVE_LDAP
48 WCHAR *dnW = NULL, *credW = NULL;
49
51
52 TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), cred, method );
53
54 if (!ld) return ~0u;
55
56 if (dn) {
57 dnW = strAtoW( dn );
58 if (!dnW) goto exit;
59 }
60 if (cred) {
61 credW = strAtoW( cred );
62 if (!credW) goto exit;
63 }
64
65 ret = ldap_bindW( ld, dnW, credW, method );
66
67exit:
68 strfreeW( dnW );
69 strfreeW( credW );
70
71#endif
72 return ret;
73}
ULONG CDECL ldap_bindW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method)
Definition: bind.c:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

◆ ldap_bindW()

ULONG CDECL ldap_bindW ( WLDAP32_LDAP ld,
PWCHAR  dn,
PWCHAR  cred,
ULONG  method 
)

Definition at line 93 of file bind.c.

94{
96#ifdef HAVE_LDAP
97 char *dnU = NULL, *credU = NULL;
98 struct berval pwd = { 0, NULL };
99 int msg;
100
102
103 TRACE( "(%p, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), cred, method );
104
105 if (!ld) return ~0u;
107
108 if (dn) {
109 dnU = strWtoU( dn );
110 if (!dnU) goto exit;
111 }
112 if (cred) {
113 credU = strWtoU( cred );
114 if (!credU) goto exit;
115
116 pwd.bv_len = strlen( credU );
117 pwd.bv_val = credU;
118 }
119
120 ret = ldap_sasl_bind( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );
121
122 if (ret == LDAP_SUCCESS)
123 ret = msg;
124 else
125 ret = ~0u;
126
127exit:
128 strfreeU( dnU );
129 strfreeU( credU );
130
131#endif
132 return ret;
133}
#define msg(x)
Definition: auth_time.c:54
#define ldap_sasl_bind
Definition: winldap.h:636
#define LDAP_SUCCESS
Definition: winldap.h:59

Referenced by ldap_bindA().

◆ ldap_sasl_bind_sA()

ULONG CDECL ldap_sasl_bind_sA ( WLDAP32_LDAP ld,
const PCHAR  dn,
const PCHAR  mechanism,
const BERVAL cred,
PLDAPControlA serverctrls,
PLDAPControlA clientctrls,
PBERVAL serverdata 
)

Definition at line 347 of file bind.c.

350{
352#ifdef HAVE_LDAP
353 WCHAR *dnW, *mechanismW = NULL;
354 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
355
357
358 TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
359 debugstr_a(mechanism), cred, serverctrls, clientctrls, serverdata );
360
361 if (!ld || !dn || !mechanism || !cred || !serverdata)
363
364 dnW = strAtoW( dn );
365 if (!dnW) goto exit;
366
367 mechanismW = strAtoW( mechanism );
368 if (!mechanismW) goto exit;
369
370 if (serverctrls) {
371 serverctrlsW = controlarrayAtoW( serverctrls );
372 if (!serverctrlsW) goto exit;
373 }
374 if (clientctrls) {
375 clientctrlsW = controlarrayAtoW( clientctrls );
376 if (!clientctrlsW) goto exit;
377 }
378
379 ret = ldap_sasl_bind_sW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, serverdata );
380
381exit:
382 strfreeW( dnW );
383 strfreeW( mechanismW );
384 controlarrayfreeW( serverctrlsW );
385 controlarrayfreeW( clientctrlsW );
386
387#endif
388 return ret;
389}
ULONG CDECL ldap_sasl_bind_sW(WLDAP32_LDAP *ld, const PWCHAR dn, const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PBERVAL *serverdata)
Definition: bind.c:413

◆ ldap_sasl_bind_sW()

ULONG CDECL ldap_sasl_bind_sW ( WLDAP32_LDAP ld,
const PWCHAR  dn,
const PWCHAR  mechanism,
const BERVAL cred,
PLDAPControlW serverctrls,
PLDAPControlW clientctrls,
PBERVAL serverdata 
)

Definition at line 413 of file bind.c.

416{
418#ifdef HAVE_LDAP
419 char *dnU, *mechanismU = NULL;
420 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
421 struct berval credU;
422
424
425 TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
426 debugstr_w(mechanism), cred, serverctrls, clientctrls, serverdata );
427
428 if (!ld || !dn || !mechanism || !cred || !serverdata)
430
431 dnU = strWtoU( dn );
432 if (!dnU) goto exit;
433
434 mechanismU = strWtoU( mechanism );
435 if (!mechanismU) goto exit;
436
437 if (serverctrls) {
438 serverctrlsU = controlarrayWtoU( serverctrls );
439 if (!serverctrlsU) goto exit;
440 }
441 if (clientctrls) {
442 clientctrlsU = controlarrayWtoU( clientctrls );
443 if (!clientctrlsU) goto exit;
444 }
445
446 credU.bv_len = cred->bv_len;
447 credU.bv_val = cred->bv_val;
448
449 ret = map_error( ldap_sasl_bind_s( ld, dnU, mechanismU, &credU,
450 serverctrlsU, clientctrlsU, (struct berval **)serverdata ));
451
452exit:
453 strfreeU( dnU );
454 strfreeU( mechanismU );
455 controlarrayfreeU( serverctrlsU );
456 controlarrayfreeU( clientctrlsU );
457
458#endif
459 return ret;
460}
#define LDAPControl
Definition: winldap.h:620

Referenced by ldap_sasl_bind_sA().

◆ ldap_sasl_bindA()

ULONG CDECL ldap_sasl_bindA ( WLDAP32_LDAP ld,
const PCHAR  dn,
const PCHAR  mechanism,
const BERVAL cred,
PLDAPControlA serverctrls,
PLDAPControlA clientctrls,
int message 
)

Definition at line 227 of file bind.c.

230{
232#ifdef HAVE_LDAP
233 WCHAR *dnW, *mechanismW = NULL;
234 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
235
237
238 TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn),
239 debugstr_a(mechanism), cred, serverctrls, clientctrls, message );
240
241 if (!ld || !dn || !mechanism || !cred || !message)
243
244 dnW = strAtoW( dn );
245 if (!dnW) goto exit;
246
247 mechanismW = strAtoW( mechanism );
248 if (!mechanismW) goto exit;
249
250 if (serverctrls) {
251 serverctrlsW = controlarrayAtoW( serverctrls );
252 if (!serverctrlsW) goto exit;
253 }
254 if (clientctrls) {
255 clientctrlsW = controlarrayAtoW( clientctrls );
256 if (!clientctrlsW) goto exit;
257 }
258
259 ret = ldap_sasl_bindW( ld, dnW, mechanismW, cred, serverctrlsW, clientctrlsW, message );
260
261exit:
262 strfreeW( dnW );
263 strfreeW( mechanismW );
264 controlarrayfreeW( serverctrlsW );
265 controlarrayfreeW( clientctrlsW );
266
267#endif
268 return ret;
269}
ULONG CDECL ldap_sasl_bindW(WLDAP32_LDAP *ld, const PWCHAR dn, const PWCHAR mechanism, const BERVAL *cred, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, int *message)
Definition: bind.c:293
Definition: tftpd.h:60

◆ ldap_sasl_bindW()

ULONG CDECL ldap_sasl_bindW ( WLDAP32_LDAP ld,
const PWCHAR  dn,
const PWCHAR  mechanism,
const BERVAL cred,
PLDAPControlW serverctrls,
PLDAPControlW clientctrls,
int message 
)

Definition at line 293 of file bind.c.

296{
298#ifdef HAVE_LDAP
299 char *dnU, *mechanismU = NULL;
300 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
301 struct berval credU;
302
304
305 TRACE( "(%p, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn),
306 debugstr_w(mechanism), cred, serverctrls, clientctrls, message );
307
308 if (!ld || !dn || !mechanism || !cred || !message)
310
311 dnU = strWtoU( dn );
312 if (!dnU) goto exit;
313
314 mechanismU = strWtoU( mechanism );
315 if (!mechanismU) goto exit;
316
317 if (serverctrls) {
318 serverctrlsU = controlarrayWtoU( serverctrls );
319 if (!serverctrlsU) goto exit;
320 }
321 if (clientctrls) {
322 clientctrlsU = controlarrayWtoU( clientctrls );
323 if (!clientctrlsU) goto exit;
324 }
325
326 credU.bv_len = cred->bv_len;
327 credU.bv_val = cred->bv_val;
328
329 ret = map_error( ldap_sasl_bind( ld, dnU, mechanismU, &credU,
330 serverctrlsU, clientctrlsU, message ));
331
332exit:
333 strfreeU( dnU );
334 strfreeU( mechanismU );
335 controlarrayfreeU( serverctrlsU );
336 controlarrayfreeU( clientctrlsU );
337
338#endif
339 return ret;
340}

Referenced by ldap_sasl_bindA().

◆ ldap_simple_bind_sA()

ULONG CDECL ldap_simple_bind_sA ( WLDAP32_LDAP ld,
PCHAR  dn,
PCHAR  passwd 
)

Definition at line 561 of file bind.c.

562{
564#ifdef HAVE_LDAP
565 WCHAR *dnW = NULL, *passwdW = NULL;
566
568
569 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), passwd );
570
571 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
572
573 if (dn) {
574 dnW = strAtoW( dn );
575 if (!dnW) goto exit;
576 }
577 if (passwd) {
578 passwdW = strAtoW( passwd );
579 if (!passwdW) goto exit;
580 }
581
582 ret = ldap_simple_bind_sW( ld, dnW, passwdW );
583
584exit:
585 strfreeW( dnW );
586 strfreeW( passwdW );
587
588#endif
589 return ret;
590}
ULONG CDECL ldap_simple_bind_sW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd)
Definition: bind.c:609

◆ ldap_simple_bind_sW()

ULONG CDECL ldap_simple_bind_sW ( WLDAP32_LDAP ld,
PWCHAR  dn,
PWCHAR  passwd 
)

Definition at line 609 of file bind.c.

610{
612#ifdef HAVE_LDAP
613 char *dnU = NULL, *passwdU = NULL;
614 struct berval pwd = { 0, NULL };
615
617
618 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), passwd );
619
620 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
621
622 if (dn) {
623 dnU = strWtoU( dn );
624 if (!dnU) goto exit;
625 }
626 if (passwd) {
627 passwdU = strWtoU( passwd );
628 if (!passwdU) goto exit;
629
630 pwd.bv_len = strlen( passwdU );
631 pwd.bv_val = passwdU;
632 }
633
634 ret = map_error( ldap_sasl_bind_s( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL ));
635
636exit:
637 strfreeU( dnU );
638 strfreeU( passwdU );
639
640#endif
641 return ret;
642}

Referenced by ldap_simple_bind_sA().

◆ ldap_simple_bindA()

ULONG CDECL ldap_simple_bindA ( WLDAP32_LDAP ld,
PCHAR  dn,
PCHAR  passwd 
)

Definition at line 467 of file bind.c.

468{
470#ifdef HAVE_LDAP
471 WCHAR *dnW = NULL, *passwdW = NULL;
472
474
475 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), passwd );
476
477 if (!ld) return ~0u;
478
479 if (dn) {
480 dnW = strAtoW( dn );
481 if (!dnW) goto exit;
482 }
483 if (passwd) {
484 passwdW = strAtoW( passwd );
485 if (!passwdW) goto exit;
486 }
487
488 ret = ldap_simple_bindW( ld, dnW, passwdW );
489
490exit:
491 strfreeW( dnW );
492 strfreeW( passwdW );
493
494#endif
495 return ret;
496}
ULONG CDECL ldap_simple_bindW(WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd)
Definition: bind.c:515

◆ ldap_simple_bindW()

ULONG CDECL ldap_simple_bindW ( WLDAP32_LDAP ld,
PWCHAR  dn,
PWCHAR  passwd 
)

Definition at line 515 of file bind.c.

516{
518#ifdef HAVE_LDAP
519 char *dnU = NULL, *passwdU = NULL;
520 struct berval pwd = { 0, NULL };
521 int msg;
522
524
525 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), passwd );
526
527 if (!ld) return ~0u;
528
529 if (dn) {
530 dnU = strWtoU( dn );
531 if (!dnU) goto exit;
532 }
533 if (passwd) {
534 passwdU = strWtoU( passwd );
535 if (!passwdU) goto exit;
536
537 pwd.bv_len = strlen( passwdU );
538 pwd.bv_val = passwdU;
539 }
540
541 ret = ldap_sasl_bind( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );
542
543 if (ret == LDAP_SUCCESS)
544 ret = msg;
545 else
546 ret = ~0u;
547
548exit:
549 strfreeU( dnU );
550 strfreeU( passwdU );
551
552#endif
553 return ret;
554}

Referenced by ldap_simple_bindA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wldap32  )

◆ WLDAP32_ldap_unbind()

ULONG CDECL WLDAP32_ldap_unbind ( WLDAP32_LDAP ld)

Definition at line 656 of file bind.c.

657{
659#ifdef HAVE_LDAP
660
661 TRACE( "(%p)\n", ld );
662
663 if (ld)
664 ret = map_error( ldap_unbind_ext( ld, NULL, NULL ));
665 else
667
668#endif
669 return ret;
670}

◆ WLDAP32_ldap_unbind_s()

ULONG CDECL WLDAP32_ldap_unbind_s ( WLDAP32_LDAP ld)

Definition at line 684 of file bind.c.

685{
687#ifdef HAVE_LDAP
688
689 TRACE( "(%p)\n", ld );
690
691 if (ld)
692 ret = map_error( ldap_unbind_ext_s( ld, NULL, NULL ));
693 else
695
696#endif
697 return ret;
698}