3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1993 Regents of the University of Michigan.
14 * BindRequest ::= SEQUENCE {
16 * name DistinguishedName, -- who
17 * authentication CHOICE {
18 * simple [0] OCTET STRING -- passwd
19 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
20 * krbv42ldap [1] OCTET STRING
21 * krbv42dsa [2] OCTET STRING
23 * sasl [3] SaslCredentials -- LDAPv3
27 * BindResponse ::= SEQUENCE {
28 * COMPONENTS OF LDAPResult,
29 * serverSaslCreds OCTET STRING OPTIONAL -- LDAPv3
38 #include <ac/socket.h>
39 #include <ac/string.h>
46 * ldap_simple_bind - bind to the ldap server (and X.500). The dn and
47 * password of the entry to which to bind are supplied. The message id
48 * of the request initiated is returned.
51 * ldap_simple_bind( ld, "cn=manager, o=university of michigan, c=us",
59 LDAP_CONST char *passwd )
66 LDAP_LOG (( "sbind", LDAP_LEVEL_ENTRY, "ldap_simple_bind\n" ));
68 Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 );
72 assert( LDAP_VALID( ld ) );
74 if ( passwd != NULL ) {
75 cred.bv_val = (char *) passwd;
76 cred.bv_len = strlen( passwd );
82 rc = ldap_sasl_bind( ld, dn, LDAP_SASL_SIMPLE, &cred,
85 return rc == LDAP_SUCCESS ? msgid : -1;
89 * ldap_simple_bind - bind to the ldap server (and X.500) using simple
90 * authentication. The dn and password of the entry to which to bind are
91 * supplied. LDAP_SUCCESS is returned upon success, the ldap error code
95 * ldap_simple_bind_s( ld, "cn=manager, o=university of michigan, c=us",
100 ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd )
105 LDAP_LOG (( "sbind", LDAP_LEVEL_ENTRY, "ldap_simple_bind_s\n" ));
107 Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind_s\n", 0, 0, 0 );
110 if ( passwd != NULL ) {
111 cred.bv_val = (char *) passwd;
112 cred.bv_len = strlen( passwd );
118 return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,