2 * Copyright (c) 1990 Regents of the University of Michigan.
11 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
17 #include <ac/socket.h>
18 #include <ac/string.h>
26 * ldap_bind - bind to the ldap server (and X.500). The dn and password
27 * of the entry to which to bind are supplied, along with the authentication
28 * method to use. The msgid of the bind request is returned on success,
29 * -1 if there's trouble. Note, the kerberos support assumes the user already
30 * has a valid tgt for now. ldap_result() should be called to find out the
31 * outcome of the bind request.
34 * ldap_bind( ld, "cn=manager, o=university of michigan, c=us", "secret",
39 ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
42 * The bind request looks like this:
43 * BindRequest ::= SEQUENCE {
45 * name DistinguishedName, -- who
46 * authentication CHOICE {
47 * simple [0] OCTET STRING -- passwd
49 * krbv42ldap [1] OCTET STRING
50 * krbv42dsa [2] OCTET STRING
54 * all wrapped up in an LDAPMessage sequence.
57 Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 );
59 switch ( authmethod ) {
60 case LDAP_AUTH_SIMPLE:
61 return( ldap_simple_bind( ld, dn, passwd ) );
64 case LDAP_AUTH_KRBV41:
65 return( ldap_kerberos_bind1( ld, dn ) );
67 case LDAP_AUTH_KRBV42:
68 return( ldap_kerberos_bind2( ld, dn ) );
72 ld->ld_errno = LDAP_AUTH_UNKNOWN;
78 * ldap_bind_s - bind to the ldap server (and X.500). The dn and password
79 * of the entry to which to bind are supplied, along with the authentication
80 * method to use. This routine just calls whichever bind routine is
81 * appropriate and returns the result of the bind (e.g. LDAP_SUCCESS or
82 * some other error indication). Note, the kerberos support assumes the
83 * user already has a valid tgt for now.
86 * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
87 * "secret", LDAP_AUTH_SIMPLE )
88 * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
89 * NULL, LDAP_AUTH_KRBV4 )
92 ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
94 Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 );
96 switch ( authmethod ) {
97 case LDAP_AUTH_SIMPLE:
98 return( ldap_simple_bind_s( ld, dn, passwd ) );
101 case LDAP_AUTH_KRBV4:
102 return( ldap_kerberos_bind_s( ld, dn ) );
104 case LDAP_AUTH_KRBV41:
105 return( ldap_kerberos_bind1_s( ld, dn ) );
107 case LDAP_AUTH_KRBV42:
108 return( ldap_kerberos_bind2_s( ld, dn ) );
112 return( ld->ld_errno = LDAP_AUTH_UNKNOWN );
117 #ifdef LDAP_REFERRALS
119 ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp,
120 char **passwdp, int *authmethodp, int freeit ))
122 ld->ld_rebindproc = rebindproc;
124 #endif /* LDAP_REFERRALS */