def usermod_pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): add_missing_object_class(ldap, 'mailSenderEntity', dn, update=False) add_missing_object_class(ldap, 'mailReceiverEntity', dn, update=False) add_missing_object_class(ldap, 'mailboxEntity', dn, update=False) normalize_mail_attrs(entry_attrs) if 'mailboxquota' in entry_attrs: quota_str = '*:storage={}M'.format(entry_attrs['mailboxquota']) entry_attrs['mailboxquota'] = quota_str return dn user_mod.register_pre_callback(usermod_pre_callback) def usermod_post_callback(self, ldap, dn, entry_attrs, *keys, **options): if 'mailboxquota' in entry_attrs: try: _, _, limit = parse_quota_rule(str(entry_attrs['mailboxquota'][0])) entry_attrs['mailboxquota'] = str(limit) except ValueError: pass return dn user_mod.register_post_callback(usermod_post_callback)
def user_add_fas_precb(self, ldap, dn, entry, attrs_list, *keys, **options): if any(option.startswith("fas") for option in options): # add fasuser object class if not self.obj.has_objectclass(entry["objectclass"], "fasuser"): entry["objectclass"].append("fasuser") # check fasuser attributes check_fasuser_attr(entry) return dn user_add.register_pre_callback(user_add_fas_precb) stageuser_add.register_pre_callback(user_add_fas_precb) def user_mod_fas_precb(self, ldap, dn, entry, attrs_list, *keys, **options): if any(option.startswith("fas") for option in options): # add fasuser object class if "objectclass" not in entry: entry_oc = ldap.get_entry(dn, ["objectclass"]) entry["objectclass"] = entry_oc["objectclass"] if not self.obj.has_objectclass(entry["objectclass"], "fasuser"): entry["objectclass"].append("fasuser") # check fasuser attributes check_fasuser_attr(entry) return dn user_mod.register_pre_callback(user_mod_fas_precb) stageuser_mod.register_pre_callback(user_mod_fas_precb)