3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1993 Regents of the University of Michigan.
13 * Portions Copyright (C) The Internet Society (1997)
14 * ASN.1 fragments are from RFC 2251; see RFC for full legal notices.
18 * BindRequest ::= SEQUENCE {
20 * name DistinguishedName, -- who
21 * authentication CHOICE {
22 * simple [0] OCTET STRING -- passwd
23 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
24 * krbv42ldap [1] OCTET STRING
25 * krbv42dsa [2] OCTET STRING
27 * sasl [3] SaslCredentials -- LDAPv3
31 * BindResponse ::= SEQUENCE {
32 * COMPONENTS OF LDAPResult,
33 * serverSaslCreds OCTET STRING OPTIONAL -- LDAPv3
42 #include <ac/socket.h>
43 #include <ac/string.h>
49 * ldap_simple_bind - bind to the ldap server (and X.500). The dn and
50 * password of the entry to which to bind are supplied. The message id
51 * of the request initiated is returned.
54 * ldap_simple_bind( ld, "cn=manager, o=university of michigan, c=us",
62 LDAP_CONST char *passwd )
69 LDAP_LOG ( OPERATION, ENTRY, "ldap_simple_bind\n", 0, 0, 0 );
71 Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 );
75 assert( LDAP_VALID( ld ) );
77 if ( passwd != NULL ) {
78 cred.bv_val = (char *) passwd;
79 cred.bv_len = strlen( passwd );
85 rc = ldap_sasl_bind( ld, dn, LDAP_SASL_SIMPLE, &cred,
88 return rc == LDAP_SUCCESS ? msgid : -1;
92 * ldap_simple_bind - bind to the ldap server (and X.500) using simple
93 * authentication. The dn and password of the entry to which to bind are
94 * supplied. LDAP_SUCCESS is returned upon success, the ldap error code
98 * ldap_simple_bind_s( ld, "cn=manager, o=university of michigan, c=us",
103 ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd )
108 LDAP_LOG ( OPERATION, ENTRY, "ldap_simple_bind_s\n", 0, 0, 0 );
110 Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind_s\n", 0, 0, 0 );
113 if ( passwd != NULL ) {
114 cred.bv_val = (char *) passwd;
115 cred.bv_len = strlen( passwd );
121 return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,