diff --git a/ldapom/attribute.py b/ldapom/attribute.py index bdd07e7..d96be87 100644 --- a/ldapom/attribute.py +++ b/ldapom/attribute.py @@ -58,6 +58,9 @@ def __deepcopy__(self, memo): c._values = copy.deepcopy(self._values) return c + def is_present(self): + return bool(self._values) + class SingleValueAttributeMixin(object): single_value = True diff --git a/ldapom/entry.py b/ldapom/entry.py index 87d0f84..3e46249 100644 --- a/ldapom/entry.py +++ b/ldapom/entry.py @@ -162,3 +162,15 @@ def can_bind(self, bind_password): :rtype: boolean """ return self._connection.can_bind(self.dn, bind_password) + + def has_attribute(self, attribute): + """Return whether or not this attribute really exists + + :param attribute: Name of the attribute + :type attribute: str + :rtype: boolean + """ + attribute = self.get_attribute(attribute) + if attribute is None: + return False + return attribute.is_present()