r6748: With reconnects, state->connection->ldap_struct can change in smbldap_search
authorVolker Lendecke <vlendec@samba.org>
Thu, 12 May 2005 08:33:27 +0000 (08:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:53 +0000 (10:56 -0500)
and friends. This should be a fix for bug 2701. Thanks to jht for giving me
access to his box!

Volker

source/passdb/pdb_ldap.c

index 7b3d84e43b344e1b09d537e91dcb5457c7e9d7db..d8c7565b64632d3bd8b46058f18d792ed1cae8b1 100644 (file)
@@ -3390,7 +3390,7 @@ struct ldap_search_state {
 static BOOL ldapsam_search_firstpage(struct pdb_search *search)
 {
        struct ldap_search_state *state = search->private;
-       LDAP *ld = state->connection->ldap_struct;
+       LDAP *ld;
        int rc = LDAP_OPERATIONS_ERROR;
 
        state->entries = NULL;
@@ -3423,8 +3423,13 @@ static BOOL ldapsam_search_firstpage(struct pdb_search *search)
                state->connection->paged_results = False;
        }
 
-       if ( ld )
-               state->current_entry = ldap_first_entry(ld, state->entries);
+        ld = state->connection->ldap_struct;
+        if ( ld == NULL) {
+                DEBUG(5, ("Don't have an LDAP connection right after a "
+                         "search\n"));
+                return False;
+        }
+        state->current_entry = ldap_first_entry(ld, state->entries);
 
        if (state->current_entry == NULL) {
                ldap_msgfree(state->entries);