Add comment explaining the previous fix.
[samba.git] / source / libads / ldap.c
index 47b9f3e4d2c58ea8ccb1249dcb2bfd9bdf6e7c1c..d8a117888eaefe4a0cce045f74f034f183a5b6e2 100644 (file)
@@ -118,6 +118,16 @@ static int ldap_search_with_timeout(LDAP *ld,
        if (gotalarm != 0)
                return LDAP_TIMELIMIT_EXCEEDED;
 
+       /*
+        * A bug in OpenLDAP means ldap_search_ext_s can return
+        * LDAP_SUCCESS but with a NULL res pointer. Cope with
+        * this. See bug #6279 for details. JRA.
+        */
+
+       if (*res == NULL) {
+               return LDAP_TIMELIMIT_EXCEEDED;
+       }
+
        return result;
 }
 
@@ -299,6 +309,8 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
        if (c_realm && *c_realm)
                got_realm = True;
 
+ again:
+
        /* we need to try once with the realm name and fallback to the
           netbios domain name if we fail (if netbios has not been disabled */
 
@@ -350,8 +362,6 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
 
        sitename = sitename_fetch(realm);
 
- again:
-
        DEBUG(6,("ads_find_dc: (cldap) looking for %s '%s'\n",
                (got_realm ? "realm" : "domain"), realm));