LDAP_BIND(3) LDAP_BIND(3) NAME ldap_bind, ldap_bind_s, ldap_simple_bind, ldap_simple_bind_s, ldap_ker- beros_bind_s, ldap_kerberos_bind1, ldap_kerberos_bind1_s, ldap_ker- beros_bind2, ldap_kerberos_bind2_s, ldap_sasl_bind, ldap_sasl_bind_s, ldap_sasl_interactive_bind_s, ldap_parse_sasl_bind_result, ldap_unbind, ldap_unbind_s - LDAP bind(2,n,1 builtins) routines LIBRARY OpenLDAP LDAP (libldap, -lldap) SYNOPSIS #include <ldap.h> int ldap_bind(LDAP *ld(1,8), const char *who, const char *cred, int method); int ldap_bind_s(LDAP *ld(1,8), const char *who, const char *cred, int method); int ldap_simple_bind(LDAP *ld(1,8), const char *who, const char *passwd(1,5)); int ldap_simple_bind_s(LDAP *ld(1,8), const char *who, const char *passwd(1,5)); int ldap_kerberos_bind_s(LDAP *ld(1,8), const char *who); int ldap_kerberos_bind1(LDAP *ld(1,8), const char *who); int ldap_kerberos_bind1_s(LDAP *ld(1,8), const char *who); int ldap_kerberos_bind2(LDAP *ld(1,8), const char *who); int ldap_kerberos_bind2_s(LDAP *ld(1,8), const char *who); int ldap_sasl_bind(LDAP *ld(1,8), const char *dn, const char *mechanism, struct berval *cred, LDAPControl *sctrls[], LDAPControl *cctrls[], int *msgidp); int ldap_sasl_bind_s(LDAP *ld(1,8), const char *dn, const char *mechanism, struct berval *cred, LDAPControl *sctrls[], LDAPControl *cctrls[], struct berval **servercredp); int ldap_parse_sasl_bind_result(LDAP *ld(1,8), LDAPMessage *res, struct berval **servercredp, int freeit); int ldap_sasl_interactive_bind_s(LDAP *ld(1,8), const char *dn, const char *mechs, LDAPControl *sctrls[], LDAPControl *cctrls[], unsigned flags, LDAP_SASL_INTERACT_PROC *interact, void *defaults); int ldap_unbind(LDAP *ld(1,8)); int ldap_unbind_s(LDAP *ld(1,8)); DESCRIPTION These routines provide various interfaces to the LDAP bind(2,n,1 builtins) operation. After an association with an LDAP server is made using ldap_init(3), an LDAP bind(2,n,1 builtins) operation should be performed before other operations are attempted over the connection. An LDAP bind(2,n,1 builtins) is required when using Version 2 of the LDAP protocol; it is optional for Version 3 but is usually needed due to security considerations. There are many types of bind(2,n,1 builtins) calls, providing simple authentication, Kerberos version(1,3,5) 4 authentication, and general routines to do either one, as well as calls using SASL (Simple Authentication and Security Layer) that can negotiate one of many different kinds of authentica- tion. Both synchronous and asynchronous versions of each variant of the bind(2,n,1 builtins) call are provided. All routines take ld(1,8) as their first param- eter, as returned from ldap_init(3). Kerberos version(1,3,5) 4 has been superseded by Kerberos version(1,3,5) 5, and the Kerberos version(1,3,5) 4 support is only provided for backward compatibility. The SASL interfaces should be used for new applications. SASL provides a general interface for using Kerberos versions 4 and 5 and many other security systems. SIMPLE AUTHENTICATION The simplest form of the bind(2,n,1 builtins) call is ldap_simple_bind_s(). It takes the DN to bind(2,n,1 builtins) as in(1,8) who, and the userPassword associated with the entry in(1,8) passwd(1,5). It returns an LDAP error(8,n) indication (see ldap_error(3)). The ldap_simple_bind() call is asynchronous, taking the same parameters but only initiating the bind(2,n,1 builtins) operation and return- ing the message id of the request it sent. The result of the operation can be obtained by a subsequent call to ldap_result(3). KERBEROS AUTHENTICATION If the LDAP library and LDAP server being contacted have been compiled with the KERBEROS option defined, Kerberos version(1,3,5) 4 authentication can be performed. As mentioned above, these Kerberos routines are provided only for backward compatibility. These routines assume the user already has obtained a ticket granting ticket. The routines take who, the DN of the entry to bind(2,n,1 builtins) as. The ldap_kerberos_bind_s() routine does both steps of the Kerberos binding process synchronously. The ldap_kerberos_bind1_s() and ldap_ker- beros_bind2_s() routines allow synchronous access(2,5) to the individual steps, authenticating to the LDAP server and X.500 DSA, respectively. The ldap_kerberos_bind1() and ldap_kerberos_bind2() routines provide equivalent asynchronous access. The ldap_kerberos_bind_s() routine is used to perform both authentica- tion steps when contacting an LDAP server that is a gateway to an X.500 DSA. This kind of server configuration is only supported in(1,8) the (very old) University of Michigan LDAP release. The OpenLDAP package no longer provides this gateway server. The standalone LDAP server pro- vided in(1,8) OpenLDAP may still be configured with Kerberos version(1,3,5) 4 sup- port, but it only requires one authentication step, and will return an error(8,n) if(3,n) the second step is attempted. Therefore, only the ldap_ker- beros_bind1() routine or its synchronous equivalent may be used when contacting an OpenLDAP server. GENERAL AUTHENTICATION The ldap_bind() and ldap_bind_s() routines can be used when the authen- tication method to use needs to be selected at runtime. They both take an extra method parameter selecting the authentication method to use. It should be set(7,n,1 builtins) to one of LDAP_AUTH_SIMPLE, LDAP_AUTH_KRBV41, or LDAP_AUTH_KRBV42, to select(2,7,2 select_tut) simple authentication, Kerberos authentica- tion to the LDAP server, or Kerberos authentication to the X.500 DSA, respectively. ldap_bind() returns the message id of the request it initiates. ldap_bind_s() returns an LDAP error(8,n) indication. SASL AUTHENTICATION Description still under construction... UNBINDING The ldap_unbind() call is used to unbind from the directory, terminate the current association, and free the resources contained in(1,8) the ld(1,8) structure. Once it is called, the connection to the LDAP server is closed, and the ld(1,8) structure is invalid. The ldap_unbind_s() call is just another name for ldap_unbind(); both of these calls are synchro- nous in(1,8) nature. ERRORS Asynchronous routines will return -1 in(1,8) case of error(8,n), setting the ld_errno parameter of the ld(1,8) structure. Synchronous routines return whatever ld_errno is set(7,n,1 builtins) to. See ldap_error(3) for more information. SEE ALSO ldap(3,5,n)(3), ldap_error(3), ldap_open(3), RFC 2222 (http://www.ietf.org), Cyrus SASL (http://asg.web.cmu.edu/sasl/) ACKNOWLEDGEMENTS OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan LDAP 3.3 Release. OpenLDAP 2.2.15 2004/07/27 LDAP_BIND(3)