Browse Source

Merge pull request #14250 from RussWhitehead/pagedSearch712x

HPCC-24881 LDAP Paged Search Control error when DN not exist

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 4 years ago
parent
commit
ba34854e34
1 changed files with 13 additions and 0 deletions
  1. 13 0
      system/security/LdapSecurity/ldapconnection.cpp

+ 13 - 0
system/security/LdapSecurity/ldapconnection.cpp

@@ -1259,6 +1259,19 @@ private:
             rc = ldap_search_ext_s(m_pLdapConn, m_pszDN, m_scope, m_pszFilter, m_pszAttrs, 0, svrCtrls, NULL, &timeOut, 0, &m_pPageBlock);
             if (rc != LDAP_SUCCESS)
             {
+                if (rc == LDAP_NO_SUCH_OBJECT)
+                {
+                    if (m_pCookie)
+                    {
+                        ber_bvfree(m_pCookie);
+                        m_pCookie = NULL;
+                    }
+#ifdef _DEBUG
+                    DBGLOG("CPagedLDAPSearch::requestNextPage: ldap_search_ext_s() : No Such Object : DN=%s", m_pszDN);
+#endif
+                    return false;
+                }
+
                 int err = GetLastError();
                 if (err && rc != LDAP_PARTIAL_RESULTS)//389DirectoryServer sometimes returns rc, but GetLastError returns 0. In this scenario continuing the query succeeds
                 {