Bug 918712

Summary: Sorting with attributes in ldapsearch gives incorrect result
Product: Red Hat Enterprise Linux 7 Reporter: Nathan Kinder <nkinder>
Component: 389-ds-baseAssignee: Rich Megginson <rmeggins>
Status: CLOSED CURRENTRELEASE QA Contact: Sankar Ramalingam <sramling>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 7.0CC: amsharma, jgalipea, nhosoi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.3.1.2-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 989692 (view as bug list) Environment:
Last Closed: 2014-06-13 10:36:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 989692    

Description Nathan Kinder 2013-03-06 18:16:25 UTC
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/389/ticket/543

I have performed sorting in ldapsearch operation with all the combination of two attributes (sn, telephonenumber). I have made the 'sn' values of all the entries same and the 'telephonenumber' values different so that the sorting order for all the search results will be same. But the sorting order for the  search results are not same as expected. When I sort with "sn", "sn telephonenumber" and "telephonenumber sn" the ordering of the search results are same. The search results of "telephonenumber" sort is different from other results. At least the search results for sorting with "telephonenumber" and "telephonenumber sn"  should give similar results as all the entries have same 'sn' value.
Note: It is reproduced in 389 DS-1.2.15

Reproducer details:
----------------------------------------------------------------------
The data I have uploaded to the database is given below
dirsrv12@dirsrv12-VirtualBox:~$ cat data.ldif
dn: uid=scarter, ou=People, dc=asiapacific,dc=hpqcorp,dc=net
cn: Sam Carter
sn: Test sn
givenname: Sam
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
uid: scarter
telephonenumber: 12

dn: uid=tmorris, ou=People, dc=asiapacific,dc=hpqcorp,dc=net
cn: Ted Morris
sn: Test sn
givenname: Ted
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
uid: tmorris
telephonenumber: 1 3

dn: uid=kvaughan, ou=People, dc=asiapacific,dc=hpqcorp,dc=net
cn: Ken kvaughan
sn: Test sn
givenname: Kirsten
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
uid: kvaughan
telephonenumber: 1   23

The sorting search results for all the combinations are given below
Sorting with sn
dirsrv12@dirsrv12-VirtualBox:~$ ldapsearch -h dirsrv12-VirtualBox -p 389 -b "ou=people,dc=asiapacific,dc=hpqcorp,dc=net" -s one -S "sn" -x "(objectclass=inetorgperson)" sn telephonenumber
# extended LDIF
#
# LDAPv3
# base <ou=people,dc=asiapacific,dc=hpqcorp,dc=net> with scope oneLevel
# filter: (objectclass=inetorgperson)
# requesting: sn telephonenumber
#

# scarter, People, asiapacific.hpqcorp.net
dn: uid=scarter,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 12

# tmorris, People, asiapacific.hpqcorp.net
dn: uid=tmorris,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1 3

# kvaughan, People, asiapacific.hpqcorp.net
dn: uid=kvaughan,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1   23

# search result
search: 2
result: 0 Success

# numResponses: 4
# numEntries: 3

Sorting with telephonenumber
dirsrv12@dirsrv12-VirtualBox:~$ ldapsearch -h dirsrv12-VirtualBox -p 389 -b "ou=people,dc=asiapacific,dc=hpqcorp,dc=net" -s one -S "telephonenumber" -x "(objectclass=inetorgperson)" sn telephonenumber
# extended LDIF
#
# LDAPv3
# base <ou=people,dc=asiapacific,dc=hpqcorp,dc=net> with scope oneLevel
# filter: (objectclass=inetorgperson)
# requesting: sn telephonenumber
#

# kvaughan, People, asiapacific.hpqcorp.net
dn: uid=kvaughan,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1   23

# tmorris, People, asiapacific.hpqcorp.net
dn: uid=tmorris,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1 3

# scarter, People, asiapacific.hpqcorp.net
dn: uid=scarter,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 12

# search result
search: 2
result: 0 Success

# numResponses: 4
# numEntries: 3

Sorting with telephonenumber sn
dirsrv12@dirsrv12-VirtualBox:~$ ldapsearch -h dirsrv12-VirtualBox -p 389 -b "ou=people,dc=asiapacific,dc=hpqcorp,dc=net" -s one -S "telephonenumber sn" -x "(objectclass=inetorgperson)" sn telephonenumber
# extended LDIF
#
# LDAPv3
# base <ou=people,dc=asiapacific,dc=hpqcorp,dc=net> with scope oneLevel
# filter: (objectclass=inetorgperson)
# requesting: sn telephonenumber
#

# scarter, People, asiapacific.hpqcorp.net
dn: uid=scarter,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 12

# tmorris, People, asiapacific.hpqcorp.net
dn: uid=tmorris,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1 3

# kvaughan, People, asiapacific.hpqcorp.net
dn: uid=kvaughan,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1   23

# search result
search: 2
result: 0 Success

# numResponses: 4
# numEntries: 3

Sorting with sn telephonenumber
dirsrv12@dirsrv12-VirtualBox:~$ ldapsearch -h dirsrv12-VirtualBox -p 389 -b "ou=people,dc=asiapacific,dc=hpqcorp,dc=net" -s one -S "sn telephonenumber" -x "(objectclass=inetorgperson)" sn telephonenumber
# extended LDIF
#
# LDAPv3
# base <ou=people,dc=asiapacific,dc=hpqcorp,dc=net> with scope oneLevel
# filter: (objectclass=inetorgperson)
# requesting: sn telephonenumber
#

# scarter, People, asiapacific.hpqcorp.net
dn: uid=scarter,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 12

# tmorris, People, asiapacific.hpqcorp.net
dn: uid=tmorris,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1 3

# kvaughan, People, asiapacific.hpqcorp.net
dn: uid=kvaughan,ou=People,dc=asiapacific,dc=hpqcorp,dc=net
sn: Test sn
telephonenumber: 1   23

# search result
search: 2
result: 0 Success

# numResponses: 4
# numEntries: 3

Comment 1 Sankar Ramalingam 2013-08-05 11:16:07 UTC
As per - https://bugzilla.redhat.com/show_bug.cgi?id=989692#c1, I am marking the bugzilla with qe_test_coverage+ flag.

Comment 2 Rich Megginson 2013-10-01 23:24:28 UTC
moving all ON_QA bugs to MODIFIED in order to add them to the errata (can't add bugs in the ON_QA state to an errata).  When the errata is created, the bugs should be automatically moved back to ON_QA.

Comment 4 Sankar Ramalingam 2013-12-20 11:26:44 UTC
Automated test cases added to clu/cluSearch.sh : trac543

Comment 5 Amita Sharma 2014-01-08 13:33:08 UTC
According to http://wiki.idm.lab.bos.redhat.com/qa/archive/beaker/RHEL-7.0-20131222.0/x86_64/389-ds-base-1.3.1.6-12.el7.x86_64/output/Linux/20131230-011250/clu/clu.run.out.13937 Report bug is VERIFIED.

Test execution for bug918712 completed, PASS
Bug trac 543/bug#918712 is fixed.
Search result /tet/testcases/DS/6.0/tet_tmp_dir//cluSearch_trac543.txt is identical to good result /tet/tet/../data/DS/6.0/clu/en//trac543.g_e.out.good
backend for dc=trac543,dc=com is trac543
modifying entry cn=USN,cn=plugins,cn=config

Comment 6 Ludek Smid 2014-06-13 10:36:17 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.