#include
int ldap_bind(LDAP *ld, const char *who, const char *cred, int method);
int ldap_bind_s(LDAP *ld, const char *who, const char *cred, int method);
int ldap_simple_bind(LDAP *ld, const char *who, const char *passwd);
int ldap_simple_bind_s(LDAP *ld, const char *who, const char *passwd);
int ldap_sasl_bind(LDAP *ld, const char *dn, const char *mechanism, struct berval *cred, LDAPControl *sctrls[], LDAPControl *cctrls[], int *msgidp);
int ldap_sasl_bind_s(LDAP *ld, const char *dn, const char *mechanism, struct berval *cred, LDAPControl *sctrls[], LDAPControl *cctrls[], struct berval **servercredp);
int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res, struct berval **servercredp, int freeit);
int ldap_sasl_interactive_bind_s(LDAP *ld, const char *dn, const char *mechs, LDAPControl *sctrls[], LDAPControl *cctrls[], unsigned flags, LDAP_SASL_INTERACT_PROC *interact, void *defaults);
int (LDAP_SASL_INTERACT_PROC)(LDAP *ld, unsigned flags, void *defaults, void *sasl_interact);
int ldap_unbind(LDAP *ld);
int ldap_unbind_s(LDAP *ld);
int ldap_unbind_ext(LDAP *ld, LDAPControl *sctrls[], LDAPControl *cctrls[]);
int ldap_unbind_ext_s(LDAP *ld, LDAPControl *sctrls[], LDAPControl *cctrls[]);
int ldap_set_rebind_proc (LDAP *ld, LDAP_REBIND_PROC *ldap_proc, void *params);
int (LDAP_REBIND_PROC)(LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *params);
These routines provide various interfaces to the LDAP bind operation. After an association with an LDAP server is made using ldap_init(3) an LDAP bind operation should be performed before other operations are attempted over the connection. An LDAP bind 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 three types of bind calls, ones providing simple authentication, ones providing SASL authentication, and general routines capable of doing either simple or SASL authentication.
SASL (Simple Authentication and Security Layer) that can negotiate one of many different kinds of authentication. Both synchronous and asynchronous versions of each variant of the bind call are provided. All routines take _l_d as their first parameter, as returned from ldap_init(3)
Many SASL mechanisms require multiple message exchanges to perform a complete authentication. Applications should generally use ldap_sasl_interactive_bind_s() rather than calling the basic ldap_sasl_bind() functions directly. The mechs parameter should contain a space-separated list of candidate mechanisms to use. If this parameter is NULL or empty the library will query the supportedSASLMechanisms attribute from the server's rootDSE for the list of SASL mechanisms the server supports. The flags parameter controls the interaction used to retrieve any necessary SASL authentication parameters and should be one of:
The interact function uses the provided defaults to handle requests from the SASL library for particular authentication parameters. There is no defined format for the defaults information; it is up to the caller to use whatever format is appropriate for the supplied interact function. The sasl_interact parameter comes from the underlying SASL library. When used with Cyrus SASL this is an array of sasl_interact_t structures. The Cyrus SASL library will prompt for a variety of inputs, including:
See the Cyrus SASL documentation for more details.
The ldap_set_rebind_proc function() sets the process to use for binding when an operation returns a referral. This function is used when an application needs to bind to another server in order to follow a referral or search continuation reference.
The function takes _l_d, the _r_e_b_i_n_d function, and the _p_a_r_a_m_s, the arbitrary data like state information which the client might need to properly rebind. The LDAP_OPT_REFERRALS option in the _l_d must be set to ON for the libraries to use the rebind function. Use the ldap_set_option function to set the value.
The rebind function parameters are as follows:
The _l_d parameter must be used by the application when binding to the referred server if the application wants the libraries to follow the referral.
The _u_r_l parameter points to the URL referral string received from the LDAP server. The LDAP application can use the ldap_url_parse(3) function to parse the string into its components.
The _r_e_q_u_e_s_t parameter specifies the type of request that generated the referral.
The _m_s_g_i_d parameter specifies the message ID of the request generating the referral.
The _p_a_r_a_m_s parameter is the same value as passed originally to the ldap_set_rebind_proc() function.
The LDAP libraries set all the parameters when they call the rebind function. The application should not attempt to free either the ld or the url structures in the rebind function.
The application must supply to the rebind function the required authentication information such as, user name, password, and certificates. The rebind function must use a synchronous bind method.
The ldap_unbind_ext() and ldap_unbind_ext_s() allows the operations to specify controls.
If the application needs stronger authentication than an anonymous bind, you need to provide a rebind process for that authentication method. The bind method must be synchronous.