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>
44 #include <ldap_cdefs.h>
51 ldap_verify(user, users_passwd, str_conn)
52 char *user, *users_passwd; /* Username and gived password */
53 char *str_conn; /* String connection to database */
62 /* Don't allow null username and passwd */
63 if ( *user == '0' || *users_passwd == '0' ) return (1);
65 buf=(char *)malloc(strlen(str_conn)+1);
67 report(LOG_DEBUG, "Error can't allocate memory");
72 ldapServer=strstr(buf, "://");
74 if(ldapServer == NULL && strlen(ldapServer) <4 ) {
76 report(LOG_DEBUG, "Error parse ldap server");
81 ldapServer=ldapServer+3;
83 ldap_port=(char *)strstr(ldapServer, ":");
85 if (ldap_port != NULL ) {
87 port=atoi(++ldap_port);
92 if ( debug & DEBUG_AUTHEN_FLAG )
93 report(LOG_DEBUG, "In verify_ldap : Before ldap_init : ldapserver = %s port= %d", ldapServer, port);
96 if( (ld = ldap_init(ldapServer, port)) == NULL)
98 report(LOG_DEBUG, "Unable to connect to LDAP server:%s port:%d",ldapServer, port);
102 err=ldap_simple_bind_s(ld, user, users_passwd);
104 if(err != LDAP_SUCCESS)
106 if ( debug & DEBUG_AUTHEN_FLAG )
107 report(LOG_DEBUG,"Error while bind : %d %s",err, ldap_err2string(err) );
113 if ( debug & DEBUG_AUTHEN_FLAG )
114 report(LOG_DEBUG, "LDAP authentication Sucess ");