diff --git a/html/includes/authentication/ldap.inc.php b/html/includes/authentication/ldap.inc.php
index 1783fb8ee2..ea71d4a15f 100644
--- a/html/includes/authentication/ldap.inc.php
+++ b/html/includes/authentication/ldap.inc.php
@@ -2,19 +2,21 @@
$ds = @ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']);
-if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) {
- $tls = ldap_start_tls($ds);
- if ($config['auth_ldap_starttls'] == 'require' && $tls == FALSE) {
- echo("
Fatal error: LDAP TLS required but not successfully negotiated:" . ldap_error($ds) . "
");
- exit;
- }
+if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require'))
+{
+ $tls = ldap_start_tls($ds);
+ if ($config['auth_ldap_starttls'] == 'require' && $tls == FALSE)
+ {
+ echo("Fatal error: LDAP TLS required but not successfully negotiated:" . ldap_error($ds) . "
");
+ exit;
+ }
}
function authenticate($username,$password)
{
global $config, $ds;
- if ($ds)
+ if ($username && $ds)
{
if ($config['auth_ldap_version'])
{