2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2012 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
15 /* Portions Copyright (c) 1993 Regents of the University of Michigan.
16 * All rights reserved.
20 * BindRequest ::= SEQUENCE {
22 * name DistinguishedName, -- who
23 * authentication CHOICE {
24 * simple [0] OCTET STRING -- passwd
25 * krbv42ldap [1] OCTET STRING -- OBSOLETE
26 * krbv42dsa [2] OCTET STRING -- OBSOLETE
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 )
68 Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 );
71 assert( LDAP_VALID( ld ) );
73 if ( passwd != NULL ) {
74 cred.bv_val = (char *) passwd;
75 cred.bv_len = strlen( passwd );
81 rc = ldap_sasl_bind( ld, dn, LDAP_SASL_SIMPLE, &cred,
84 return rc == LDAP_SUCCESS ? msgid : -1;
88 * ldap_simple_bind - bind to the ldap server (and X.500) using simple
89 * authentication. The dn and password of the entry to which to bind are
90 * supplied. LDAP_SUCCESS is returned upon success, the ldap error code
94 * ldap_simple_bind_s( ld, "cn=manager, o=university of michigan, c=us",
99 ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd )
103 Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind_s\n", 0, 0, 0 );
105 if ( passwd != NULL ) {
106 cred.bv_val = (char *) passwd;
107 cred.bv_len = strlen( passwd );
113 return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,