mirror of
https://github.com/samba-team/samba.git
synced 2025-07-22 16:59:09 +03:00
python/common: add __cmp__ function to dsdb_Dn similar to parsed_dn_compare()
Linked attribute values are sorted by objectGUID of the link target. For C code we have parsed_dn_compare() to implement the logic, the same is now available on python dsdb_Dn objects. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
|
||||
import ldb
|
||||
import dsdb
|
||||
from samba.ndr import ndr_pack
|
||||
from samba.dcerpc import misc
|
||||
import binascii
|
||||
|
||||
|
||||
@ -93,6 +95,21 @@ class dsdb_Dn(object):
|
||||
def __str__(self):
|
||||
return self.prefix + str(self.dn.extended_str(mode=1))
|
||||
|
||||
def __cmp__(self, other):
|
||||
''' compare dsdb_Dn values similar to parsed_dn_compare()'''
|
||||
dn1 = self
|
||||
dn2 = other
|
||||
guid1 = dn1.dn.get_extended_component("GUID")
|
||||
guid1b = ndr_pack(misc.GUID(guid1))
|
||||
guid2 = dn2.dn.get_extended_component("GUID")
|
||||
guid2b = ndr_pack(misc.GUID(guid2))
|
||||
|
||||
v = cmp(guid1, guid2)
|
||||
if v != 0:
|
||||
return v
|
||||
v = cmp(dn1.binary, dn2.binary)
|
||||
return v
|
||||
|
||||
def get_binary_integer(self):
|
||||
'''return binary part of a dsdb_Dn as an integer, or None'''
|
||||
if self.prefix == '':
|
||||
|
Reference in New Issue
Block a user