Ejemplo n.º 1
0
def groupadd_pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys,
                          **options):
    if 'alias' in entry_attrs:
        add_missing_object_class(ldap,
                                 'mailenabledgroup',
                                 dn,
                                 entry_attrs,
                                 update=False)
    return dn
Ejemplo n.º 2
0
def idoverrideuser_pre_callback(self, ldap, dn, found, not_found,
                                *keys, **options):
    assert isinstance(dn, DN)
    if 'idoverrideuser' in options:
        for id in found['member']['idoverrideuser']:
            # new_dn = self.api.Object.idoverrideuser.get_dn(id, o)
            try:
                e = ldap.get_entry(id, ['*'])
            except errors.NotFound:
                # We are not adding an object here, only modifying existing one
                continue
            e = add_missing_object_class(ldap, 'nsmemberof',
                                         id, entry_attrs=e, update=True)
    return dn
Ejemplo n.º 3
0
def hostadd_pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys,
                         **options):
    if not options.get('disablemail'):
        entry_attrs.update(
            add_missing_object_class(ldap,
                                     'mailsenderentity',
                                     dn,
                                     entry_attrs,
                                     update=False))
        if 'primarymail' not in entry_attrs:
            config = ldap.get_ipa_config()
            entry_attrs['primarymail'] = normalize_and_validate_email(
                entry_attrs['serverhostname'], config)

        entry_attrs['cansendexternally'] = entry_attrs.get(
            'cansendexternally', False)

    return dn
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def useradd_pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys,
                         **options):
    add_missing_object_class(ldap,
                             'mailSenderEntity',
                             dn,
                             entry_attrs,
                             update=False)
    add_missing_object_class(ldap,
                             'mailReceiverEntity',
                             dn,
                             entry_attrs,
                             update=False)
    add_missing_object_class(ldap,
                             'mailboxEntity',
                             dn,
                             entry_attrs,
                             update=False)

    if 'primarymail' not in entry_attrs:
        if 'mail' in entry_attrs:
            entry_attrs['primarymail'] = entry_attrs['mail'][0]

    normalize_mail_attrs(entry_attrs)

    if 'mailboxquota' in entry_attrs:
        try:
            quota = int(entry_attrs['mailboxquota'])
        except ValueError:
            raise errors.ValidationError(name='mailboxquota',
                                         error='not a number')
    else:
        dovecot_config = self.api.Command['dovecotconfig_show'](
            all=True, raw=True)['result']
        quota = int(dovecot_config.get('defaultmailboxquota')[0])

    quota_str = '*:storage={}M'.format(quota)
    entry_attrs['mailboxquota'] = quota_str

    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