if 'mailboxtransport' not in entry_attrs: postfix_config = self.api.Command['postfixconfig_show']( all=True, raw=True)['result'] entry_attrs['mailboxtransport'] = postfix_config.get( 'defaultmailboxtransport') entry_attrs['canreceiveexternally'] = entry_attrs.get( 'canreceiveexternally', True) entry_attrs['cansendexternally'] = entry_attrs.get('cansendexternally', True) return dn user_add.register_pre_callback(useradd_pre_callback) def useradd_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_add.register_post_callback(useradd_post_callback)
msg = _("invalid e-mail format: %(email)s") raise errors.ValidationError(name="fasrhbzemail", errors=msg % {"email": fasrhbzemail}) 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