Only unbind ldap connection if bind succeeded
[exim.git] / src / src / lookups / ldap.c
index bb29b43afcae998970e83bd62139b75f8aa5d1c9..6129b4bfeea6b1bf022126ab5bdecd0840fa8f15 100644 (file)
@@ -1367,7 +1367,8 @@ while ((lcp = ldap_connections) != NULL)
   {
   DEBUG(D_lookup) debug_printf("unbind LDAP connection to %s:%d\n", lcp->host,
     lcp->port);
-  ldap_unbind(lcp->ld);
+  if(lcp->bound == TRUE)
+    ldap_unbind(lcp->ld);
   ldap_connections = lcp->next;
   }
 }