2 * Copyright (c) 1990 Regents of the University of Michigan.
9 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
24 #include <sys/types.h>
25 #include <sys/socket.h>
35 * ldap_bind - bind to the ldap server (and X.500). The dn and password
36 * of the entry to which to bind are supplied, along with the authentication
37 * method to use. The msgid of the bind request is returned on success,
38 * -1 if there's trouble. Note, the kerberos support assumes the user already
39 * has a valid tgt for now. ldap_result() should be called to find out the
40 * outcome of the bind request.
43 * ldap_bind( ld, "cn=manager, o=university of michigan, c=us", "secret",
48 ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
51 * The bind request looks like this:
52 * BindRequest ::= SEQUENCE {
54 * name DistinguishedName, -- who
55 * authentication CHOICE {
56 * simple [0] OCTET STRING -- passwd
58 * krbv42ldap [1] OCTET STRING
59 * krbv42dsa [2] OCTET STRING
63 * all wrapped up in an LDAPMessage sequence.
66 Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 );
68 switch ( authmethod ) {
69 case LDAP_AUTH_SIMPLE:
70 return( ldap_simple_bind( ld, dn, passwd ) );
73 case LDAP_AUTH_KRBV41:
74 return( ldap_kerberos_bind1( ld, dn ) );
76 case LDAP_AUTH_KRBV42:
77 return( ldap_kerberos_bind2( ld, dn ) );
81 ld->ld_errno = LDAP_AUTH_UNKNOWN;
87 * ldap_bind_s - bind to the ldap server (and X.500). The dn and password
88 * of the entry to which to bind are supplied, along with the authentication
89 * method to use. This routine just calls whichever bind routine is
90 * appropriate and returns the result of the bind (e.g. LDAP_SUCCESS or
91 * some other error indication). Note, the kerberos support assumes the
92 * user already has a valid tgt for now.
95 * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
96 * "secret", LDAP_AUTH_SIMPLE )
97 * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
98 * NULL, LDAP_AUTH_KRBV4 )
101 ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
103 Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 );
105 switch ( authmethod ) {
106 case LDAP_AUTH_SIMPLE:
107 return( ldap_simple_bind_s( ld, dn, passwd ) );
110 case LDAP_AUTH_KRBV4:
111 return( ldap_kerberos_bind_s( ld, dn ) );
113 case LDAP_AUTH_KRBV41:
114 return( ldap_kerberos_bind1_s( ld, dn ) );
116 case LDAP_AUTH_KRBV42:
117 return( ldap_kerberos_bind2_s( ld, dn ) );
121 return( ld->ld_errno = LDAP_AUTH_UNKNOWN );
126 #ifdef LDAP_REFERRALS
128 ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp,
129 char **passwdp, int *authmethodp, int freeit ))
131 ld->ld_rebindproc = rebindproc;
133 #endif /* LDAP_REFERRALS */