diff options
Diffstat (limited to 'source4/lib/ldb/ldb.py')
-rw-r--r-- | source4/lib/ldb/ldb.py | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py index ebf8f6025a..ab2a68a4b3 100644 --- a/source4/lib/ldb/ldb.py +++ b/source4/lib/ldb/ldb.py @@ -71,6 +71,13 @@ class Dn(object): def __init__(self, *args, **kwargs): _ldb.Dn_swiginit(self,_ldb.new_Dn(*args, **kwargs)) __swig_destroy__ = _ldb.delete_Dn + def __eq__(self, other): + if isinstance(other, self.__class__): + return self.__cmp__(other) == 0 + if isinstance(other, str): + return str(self) == other + return False + Dn.validate = new_instancemethod(_ldb.Dn_validate,None,Dn) Dn.get_casefold = new_instancemethod(_ldb.Dn_get_casefold,None,Dn) Dn.__str__ = new_instancemethod(_ldb.Dn___str__,None,Dn) @@ -94,16 +101,27 @@ class ldb_msg_element(object): def __init__(self): raise AttributeError, "No constructor defined" __repr__ = _swig_repr __swig_destroy__ = _ldb.delete_ldb_msg_element + def __getitem__(self, i): + ret = self.get(i) + if ret is None: + raise KeyError("no such value") + return ret + def __eq__(self, other): - if (isinstance(other, str) and - len(set(self)) == 1 and - set(self).pop() == other): + if (len(self) == 1 and self.get(0) == other): return True - return self.__cmp__(other) == 0 - + if isinstance(other, self.__class__): + return self.__cmp__(other) == 0 + o = iter(other) + for i in range(len(self)): + if self.get(i) != o.next(): + return False + return True ldb_msg_element.__iter__ = new_instancemethod(_ldb.ldb_msg_element___iter__,None,ldb_msg_element) ldb_msg_element.__set__ = new_instancemethod(_ldb.ldb_msg_element___set__,None,ldb_msg_element) +ldb_msg_element.__len__ = new_instancemethod(_ldb.ldb_msg_element___len__,None,ldb_msg_element) +ldb_msg_element.get = new_instancemethod(_ldb.ldb_msg_element_get,None,ldb_msg_element) ldb_msg_element.__cmp__ = new_instancemethod(_ldb.ldb_msg_element___cmp__,None,ldb_msg_element) ldb_msg_element_swigregister = _ldb.ldb_msg_element_swigregister ldb_msg_element_swigregister(ldb_msg_element) @@ -181,10 +199,19 @@ class Ldb(object): if url is not None: self.connect(url, flags, options) + def search(self, base=None, scope=SCOPE_DEFAULT, expression=None, + attrs=None, controls=None): + parsed_controls = None + if controls is not None: + parsed_controls = self.parse_control_strings(controls) + return self.search_ex(base, scope, expression, attrs, + parsed_controls) + Ldb.connect = new_instancemethod(_ldb.Ldb_connect,None,Ldb) -Ldb.search = new_instancemethod(_ldb.Ldb_search,None,Ldb) +Ldb.search_ex = new_instancemethod(_ldb.Ldb_search_ex,None,Ldb) Ldb.delete = new_instancemethod(_ldb.Ldb_delete,None,Ldb) Ldb.rename = new_instancemethod(_ldb.Ldb_rename,None,Ldb) +Ldb.parse_control_strings = new_instancemethod(_ldb.Ldb_parse_control_strings,None,Ldb) Ldb.add = new_instancemethod(_ldb.Ldb_add,None,Ldb) Ldb.modify = new_instancemethod(_ldb.Ldb_modify,None,Ldb) Ldb.get_config_basedn = new_instancemethod(_ldb.Ldb_get_config_basedn,None,Ldb) |