def move(self, dn, newdn): """Move LDAP object from 'dn' to 'newdn'.""" newrdn = get_rdn(newdn) parent1 = get_parent_dn(dn) parent2 = get_parent_dn(newdn) if parent1 != parent2: self.lo.rename_s(compatible_modstring(unicode(dn)), compatible_modstring(unicode(newrdn)), compatible_modstring(unicode(parent2))) else: self.lo.modrdn_s(compatible_modstring(unicode(dn)), compatible_modstring(unicode(newrdn)))
def create(self, dn, attrs): """Create LDAP object at 'dn' with attributes 'attrs'.""" ldif = modlist.addModlist(attrs) self.lo.add_s(compatible_modstring(unicode(dn)), ldif)
def remove_from_attribute(self, dn, key, value): """Remove 'value' from attribute 'key' of LDAP object at 'dn'.""" ml = [(ldap.MOD_DELETE, key, compatible_modstring(unicode(value)))] self.lo.modify_s(compatible_modstring(unicode(dn)), ml)
def append_to_attribute(self, dn, key, value): """Add 'value' to attribute 'key' of LDAP object at 'dn'.""" ml = [(ldap.MOD_ADD, key, compatible_modstring(unicode(value)))] self.lo.modify_s(compatible_modstring(unicode(dn)), ml)
def delete_attribute(self, dn, key): """Delete attribute 'key' of LDAP object at 'dn'.""" ml = [(ldap.MOD_DELETE, key, None)] self.lo.modify_s(compatible_modstring(unicode(dn)), ml)
def set_attribute(self, dn, key, value): """Set attribute 'key' of LDAP object at 'dn' to 'value'.""" ml = [(ldap.MOD_REPLACE, key, compatible_modstring(unicode(value)))] self.lo.modify_s(compatible_modstring(unicode(dn)), ml)
def delete(self, dn): """Delete LDAP object at 'dn'.""" self.lo.delete_s(compatible_modstring(unicode(dn)))