2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1990 Regents of the University of Michigan.
17 #include <ac/socket.h>
18 #include <ac/string.h>
25 * ldap_bind - bind to the ldap server (and X.500). The dn and password
26 * of the entry to which to bind are supplied, along with the authentication
27 * method to use. The msgid of the bind request is returned on success,
28 * -1 if there's trouble. Note, the kerberos support assumes the user already
29 * has a valid tgt for now. ldap_result() should be called to find out the
30 * outcome of the bind request.
33 * ldap_bind( ld, "cn=manager, o=university of michigan, c=us", "secret",
38 ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
41 * The bind request looks like this:
42 * BindRequest ::= SEQUENCE {
44 * name DistinguishedName, -- who
45 * authentication CHOICE {
46 * simple [0] OCTET STRING -- passwd
48 * krbv42ldap [1] OCTET STRING
49 * krbv42dsa [2] OCTET STRING
53 * all wrapped up in an LDAPMessage sequence.
56 Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 );
58 switch ( authmethod ) {
59 case LDAP_AUTH_SIMPLE:
60 return( ldap_simple_bind( ld, dn, passwd ) );
63 case LDAP_AUTH_KRBV41:
64 return( ldap_kerberos_bind1( ld, dn ) );
66 case LDAP_AUTH_KRBV42:
67 return( ldap_kerberos_bind2( ld, dn ) );
71 ld->ld_errno = LDAP_AUTH_UNKNOWN;
77 * ldap_bind_s - bind to the ldap server (and X.500). The dn and password
78 * of the entry to which to bind are supplied, along with the authentication
79 * method to use. This routine just calls whichever bind routine is
80 * appropriate and returns the result of the bind (e.g. LDAP_SUCCESS or
81 * some other error indication). Note, the kerberos support assumes the
82 * user already has a valid tgt for now.
85 * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
86 * "secret", LDAP_AUTH_SIMPLE )
87 * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
88 * NULL, LDAP_AUTH_KRBV4 )
91 ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
93 Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 );
95 switch ( authmethod ) {
96 case LDAP_AUTH_SIMPLE:
97 return( ldap_simple_bind_s( ld, dn, passwd ) );
100 case LDAP_AUTH_KRBV4:
101 return( ldap_kerberos_bind_s( ld, dn ) );
103 case LDAP_AUTH_KRBV41:
104 return( ldap_kerberos_bind1_s( ld, dn ) );
106 case LDAP_AUTH_KRBV42:
107 return( ldap_kerberos_bind2_s( ld, dn ) );
111 return( ld->ld_errno = LDAP_AUTH_UNKNOWN );
116 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
118 ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp,
119 char **passwdp, int *authmethodp, int freeit ))
121 ld->ld_rebindproc = rebindproc;
123 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */