- /* 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);
+ }
+ }