*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
*/
/*
gid_t gid;
int timeout;
int authbind;
+ int initbind;
int deref;
int protocol_version;
int tls;
if (p)
sscanf(p,"%d",&ldap->authbind);
+ if (!read_env("LDAP_INITBIND", &p, "", 0, "1"))
+ return (0);
+
+ if (p)
+ sscanf(p,"%d",&ldap->initbind);
+
if (!read_env("LDAP_BASEDN",&ldap->basedn,
"You need to specify a basedn in config file",1,NULL))
return 0;
/* Set dereferencing mode */
if (ldaperror(ldrc = ldap_set_option(my_ldap_fp, LDAP_OPT_DEREF,
(void *) & my_ldap.deref)) != LDAP_SUCCESS)
- {
+ {
const char *s=ldap_err2string(ldrc);
err("ldap_set_option(DEREF) failed: %s", s);
authldapclose();
ldapconnfailure();
return (-1);
- }
+ }
#endif
- /* Bind to server */
- if (courier_authdebug_login_level >= 2)
- {
- DPRINTF("binding to LDAP server as DN '%s', password '%s'",
- my_ldap.binddn ? my_ldap.binddn : "<null>",
- my_ldap.bindpw ? my_ldap.bindpw : "<null>");
- }
- else
- {
- DPRINTF("binding to LDAP server as DN '%s'",
- my_ldap.binddn ? my_ldap.binddn : "<null>");
- }
-
- if (ldaperror(ldrc = l_simple_bind_s(my_ldap_fp,
- my_ldap.binddn,
- my_ldap.bindpw)) != LDAP_SUCCESS)
- {
- const char *s=ldap_err2string(ldrc);
-
- err("ldap_simple_bind_s failed: %s", s);
- authldapclose();
- ldapconnfailure();
- return (-1);
- }
+ if(my_ldap.initbind)
+ {
+ /* Bind to server */
+ if (courier_authdebug_login_level >= 2)
+ {
+ DPRINTF("binding to LDAP server as DN '%s', password '%s'",
+ my_ldap.binddn ? my_ldap.binddn : "<null>",
+ my_ldap.bindpw ? my_ldap.bindpw : "<null>");
+ }
+ else
+ {
+ DPRINTF("binding to LDAP server as DN '%s'",
+ my_ldap.binddn ? my_ldap.binddn : "<null>");
+ }
+
+ if (ldaperror(ldrc = l_simple_bind_s(my_ldap_fp,
+ my_ldap.binddn,
+ my_ldap.bindpw))
+ != LDAP_SUCCESS)
+ {
+ const char *s=ldap_err2string(ldrc);
+
+ err("ldap_simple_bind_s failed: %s", s);
+ authldapclose();
+ ldapconnfailure();
+ return (-1);
+ }
+ }
return (0);
}
char *v;
const char *aname;
- if (ldapopen()) return (1);
+ if (ldapopen()) return (-1);
if (my_ldap.emailmap[0] == 0 || strchr(user, '@') == NULL)
return (auth_ldap_do3(service, my_ldap.mail,
int i, j;
int msgid;
- if (ldapopen()) return;
+ if (ldapopen())
+ {
+ (*cb_func)(NULL, 0, 0, NULL, NULL, NULL, void_arg);
+ return;
+ }
read_env("LDAP_MAIL", &attributes[0], "", 0, "mail");
read_env("LDAP_UID", &attributes[1], "", 0, 0);