when sorting a record that does not have the requested sort attribute
then put those records last in the sort result
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;
}