diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php
index 155816187f798a92fff58342deff77774e07098b..17d4722118f7b0169af4baea1873b24db8999335 100644
--- a/htdocs/contact.class.php
+++ b/htdocs/contact.class.php
@@ -147,14 +147,13 @@ class Contact
 		{
 		  echo "LDAP bind failed...";
 		}	 
-	      ldap_close($ds);
+	      ldap_close($ds);	    
+	    }
+	  else
+	    {
+	      echo "Unable to connect to LDAP server";
 	    }
 	}
-      else
-	{
-	  echo "Unable to connect to LDAP server";
-	}
-      
       return $result;
     }
 
@@ -287,11 +286,12 @@ class Contact
 		  echo "LDAP bind failed...";
 		}	      	      
 	      ldap_close($ds);
+	    
+	    }
+	  else
+	    {
+	      echo "Unable to connect to LDAP server";
 	    }
-	}
-      else
-	{
-	  echo "Unable to connect to LDAP server";
 	}
       
       return $result;