2 Verify that this user/password is valid per a database LDAP server
3 Return 1 if verified, 0 otherwise.
5 Format of connection string (look like internet URL):
9 -------------------------------------------------------
10 patrick.harpes@tudor.lu http://www.santel.lu
15 Dependencies: You need to get the OpenLDAP libraries
16 from http://www.openldap.org
18 License: tac_ldap is free software; you can redistribute it
19 and/or modify it under the terms of the GNU General Public License
20 as published by the Free Software Foundation; either version 2,
21 or (at your option) any later version.
22 --------------------------------------------------------------------------
24 Ok i am back again..:)
25 I changed lot of thing.. First off all i add port feature to ldap string.
26 And also add more check for buffer overflows.
28 Connect format would be:
29 ldap://LDAP-hostname:100
31 Port name isn't required.. I would like to change format with :
32 ldap://LDAP-hostname:100/dn_for_user&dn_for_passwd
34 devrim seral <devrim@gazi.edu.tr>
48 #include <ldap_cdefs.h>
50 #include "ldap_author.h"
56 int ldap_verify TAC_ARGS((const char *user, const char *users_passwd, const char *str_conn));
59 ldap_verify(user, users_passwd, str_conn)
60 const char *user; /* username ... */
61 const char *users_passwd; /* ... and given password */
62 const char *str_conn; /* string connection to database */
71 /* Don't allow null username and passwd */
72 if ( *user == '0' || *users_passwd == '0' ) return (1);
74 buf = (char *) tac_malloc(strlen(str_conn)+1);
77 ldapServer=strstr(buf, "://");
79 if(ldapServer == NULL && strlen(ldapServer) <4 ) {
81 report(LOG_DEBUG, "Error parse ldap server");
86 ldapServer=ldapServer+3;
88 ldap_port=(char *)strstr(ldapServer, ":");
90 if (ldap_port != NULL ) {
92 port=atoi(++ldap_port);
97 if ( debug & DEBUG_AUTHEN_FLAG )
98 report(LOG_DEBUG, "In verify_ldap : Before ldap_init : ldapserver = %s port= %d", ldapServer, port);
101 if( (ld = ldap_init(ldapServer, port)) == NULL)
103 report(LOG_DEBUG, "Unable to connect to LDAP server:%s port:%d",ldapServer, port);
107 err=ldap_simple_bind_s(ld, (/* de-const */ char *) user, (/* de-const */ char *) users_passwd);
109 if(err != LDAP_SUCCESS)
111 if ( debug & DEBUG_AUTHEN_FLAG )
112 report(LOG_DEBUG,"Error while bind : %d %s",err, ldap_err2string(err) );
118 if ( debug & DEBUG_AUTHEN_FLAG )
119 report(LOG_DEBUG, "LDAP authentication Sucess ");
129 #endif /* USE_LDAP */