fixed server side sort control
authorAndrew Tridgell <tridge@samba.org>
Wed, 10 Jun 2009 00:33:53 +0000 (10:33 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 10 Jun 2009 00:33:53 +0000 (10:33 +1000)
when sorting a record that does not have the requested sort attribute
then put those records last in the sort result

source4/lib/ldb/modules/sort.c

index b4f76e1007a40204e6f71844b60f52aaeeb49a3b..a95a86140c4df5071c22436b99266bfbad1f6df3 100644 (file)
@@ -117,10 +117,13 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
        el1 = ldb_msg_find_element(*msg1, ac->attributeName);
        el2 = ldb_msg_find_element(*msg2, ac->attributeName);
 
-       if (!el1 || !el2) {
-               /* the attribute was not found return and
-                * set an error */
-               ac->sort_result = LDB_ERR_UNWILLING_TO_PERFORM;
+       if (!el1 && el2) {
+               return 1;
+       }
+       if (el1 && !el2) {
+               return -1;
+       }
+       if (!el1 && !el2) {
                return 0;
        }