Ejemplo n.º 1
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     assert isinstance(dn, DN)
     convert_nsaccountlock(entry_attrs)
     self.obj._convert_manager(entry_attrs, **options)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     convert_sshpubkey_post(ldap, dn, entry_attrs)
     return dn
Ejemplo n.º 2
0
 def post_callback(self, ldap, entries, truncated, *args, **options):
     truncated = super(idoverrideuser_find, self).post_callback(
         ldap, entries, truncated, *args, **options)
     for entry in entries:
         convert_sshpubkey_post(entry)
         self.obj.convert_usercertificate_post(entry, **options)
     return truncated
Ejemplo n.º 3
0
 def post_common_callback(self, ldap, dn, entry_attrs, *keys, **options):
     assert isinstance(dn, DN)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     self.obj.convert_usercertificate_post(entry_attrs, **options)
     convert_sshpubkey_post(entry_attrs)
     remove_sshpubkey_from_output_post(self.context, entry_attrs)
     radius_dn2pk(self.api, entry_attrs)
Ejemplo n.º 4
0
 def post_callback(self, ldap, entries, truncated, *args, **options):
     truncated = super(idoverrideuser_find, self).post_callback(
         ldap, entries, truncated, *args, **options)
     for entry in entries:
         convert_sshpubkey_post(entry)
         self.obj.convert_usercertificate_post(entry, **options)
     return truncated
Ejemplo n.º 5
0
 def post_common_callback(self, ldap, dn, entry_attrs, *keys, **options):
     assert isinstance(dn, DN)
     self.obj.convert_usercertificate_post(entry_attrs, **options)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     convert_sshpubkey_post(entry_attrs)
     if 'nsaccountlock' in entry_attrs:
         convert_nsaccountlock(entry_attrs)
     radius_dn2pk(self.api, entry_attrs)
Ejemplo n.º 6
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     assert isinstance(dn, DN)
     convert_nsaccountlock(entry_attrs)
     self.obj._convert_manager(entry_attrs, **options)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     convert_sshpubkey_post(ldap, dn, entry_attrs)
     radius_dn2pk(self.api, entry_attrs)
     return dn
Ejemplo n.º 7
0
 def post_common_callback(self, ldap, entries, lockout=False, **options):
     for attrs in entries:
         self.obj.convert_usercertificate_post(attrs, **options)
         if (lockout):
             attrs['nsaccountlock'] = True
         else:
             convert_nsaccountlock(attrs)
         convert_sshpubkey_post(attrs)
     remove_sshpubkey_from_output_list_post(self.context, entries)
Ejemplo n.º 8
0
 def post_common_callback(self, ldap, entries, lockout=False, **options):
     for attrs in entries:
         self.obj.get_password_attributes(ldap, attrs.dn, attrs)
         self.obj.convert_usercertificate_post(attrs, **options)
         if (lockout):
             attrs['nsaccountlock'] = True
         else:
             convert_nsaccountlock(attrs)
         convert_sshpubkey_post(ldap, attrs.dn, attrs)
Ejemplo n.º 9
0
 def post_callback(self, ldap, entries, truncated, *args, **options):
     if options.get('pkey_only', False):
         return truncated
     for attrs in entries:
         self.obj.convert_manager(attrs, **options)
         self.obj.get_password_attributes(ldap, attrs.dn, attrs)
         convert_nsaccountlock(attrs)
         convert_sshpubkey_post(ldap, attrs.dn, attrs)
     return truncated
Ejemplo n.º 10
0
 def post_common_callback(self, ldap, entries, lockout=False, **options):
     for attrs in entries:
         self.obj.get_password_attributes(ldap, attrs.dn, attrs)
         self.obj.convert_usercertificate_post(attrs, **options)
         if (lockout):
             attrs['nsaccountlock'] = True
         else:
             convert_nsaccountlock(attrs)
         convert_sshpubkey_post(ldap, attrs.dn, attrs)
Ejemplo n.º 11
0
 def post_callback(self, ldap, entries, truncated, *args, **options):
     if options.get('pkey_only', False):
         return truncated
     for entry in entries:
         (dn, attrs) = entry
         self.obj._convert_manager(attrs, **options)
         self.obj.get_password_attributes(ldap, dn, attrs)
         convert_nsaccountlock(attrs)
         convert_sshpubkey_post(ldap, dn, attrs)
     return truncated
Ejemplo n.º 12
0
 def post_common_callback(self, ldap, dn, entry_attrs, **options):
     assert isinstance(dn, DN)
     if options.get('random', False):
         try:
             entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
         except AttributeError:
             # if both randompassword and userpassword options were used
             pass
     convert_nsaccountlock(entry_attrs)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     self.obj.convert_usercertificate_post(entry_attrs, **options)
     convert_sshpubkey_post(ldap, dn, entry_attrs)
     radius_dn2pk(self.api, entry_attrs)
Ejemplo n.º 13
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     assert isinstance(dn, DN)
     if options.get('random', False):
         try:
             entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
         except AttributeError:
             # if both randompassword and userpassword options were used
             pass
     convert_nsaccountlock(entry_attrs)
     self.obj._convert_manager(entry_attrs, **options)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     convert_sshpubkey_post(ldap, dn, entry_attrs)
     return dn
Ejemplo n.º 14
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        config = ldap.get_ipa_config()
        # add the user we just created into the default primary group
        def_primary_group = config.get('ipadefaultprimarygroup')
        group_dn = self.api.Object['group'].get_dn(def_primary_group)

        # if the user is already a member of default primary group,
        # do not raise error
        # this can happen if automember rule or default group is set
        try:
            ldap.add_entry_to_group(dn, group_dn)
        except errors.AlreadyGroupMember:
            pass

        self.obj.convert_manager(entry_attrs, **options)
        # delete description attribute NO_UPG_MAGIC if present
        if options.get('noprivate', False):
            if not options.get('all', False):
                desc_attr = ldap.get_entry(dn, ['description'])
                entry_attrs.update(desc_attr)
            if 'description' in entry_attrs and NO_UPG_MAGIC in entry_attrs[
                    'description']:
                entry_attrs['description'].remove(NO_UPG_MAGIC)
                kw = {
                    'setattr':
                    unicode('description=%s' %
                            ','.join(entry_attrs['description']))
                }
                try:
                    self.api.Command['user_mod'](keys[-1], **kw)
                except (errors.EmptyModlist, errors.NotFound):
                    pass

        # Fetch the entry again to update memberof, mep data, etc updated
        # at the end of the transaction.
        newentry = ldap.get_entry(dn, ['*'])
        entry_attrs.update(newentry)

        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(
                    getattr(context, 'randompassword'))
            except AttributeError:
                # if both randompassword and userpassword options were used
                pass

        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        convert_sshpubkey_post(ldap, dn, entry_attrs)
        radius_dn2pk(self.api, entry_attrs)
        return dn
Ejemplo n.º 15
0
Archivo: user.py Proyecto: msrb/freeipa
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        config = ldap.get_ipa_config()
        # add the user we just created into the default primary group
        def_primary_group = config.get('ipadefaultprimarygroup')
        group_dn = self.api.Object['group'].get_dn(def_primary_group)

        # if the user is already a member of default primary group,
        # do not raise error
        # this can happen if automember rule or default group is set
        try:
            ldap.add_entry_to_group(dn, group_dn)
        except errors.AlreadyGroupMember:
            pass

        self.obj.convert_manager(entry_attrs, **options)
        # delete description attribute NO_UPG_MAGIC if present
        if options.get('noprivate', False):
            if not options.get('all', False):
                desc_attr = ldap.get_entry(dn, ['description'])
                entry_attrs.update(desc_attr)
            if 'description' in entry_attrs and NO_UPG_MAGIC in entry_attrs['description']:
                entry_attrs['description'].remove(NO_UPG_MAGIC)
                kw = {'setattr': unicode('description=%s' % ','.join(entry_attrs['description']))}
                try:
                    self.api.Command['user_mod'](keys[-1], **kw)
                except (errors.EmptyModlist, errors.NotFound):
                    pass

        # Fetch the entry again to update memberof, mep data, etc updated
        # at the end of the transaction.
        newentry = ldap.get_entry(dn, ['*'])
        entry_attrs.update(newentry)

        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
            except AttributeError:
                # if both randompassword and userpassword options were used
                pass

        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        convert_sshpubkey_post(ldap, dn, entry_attrs)
        radius_dn2pk(self.api, entry_attrs)
        self.obj.get_preserved_attribute(entry_attrs, options)

        self.post_common_callback(ldap, dn, entry_attrs, **options)

        return dn
Ejemplo n.º 16
0
 def post_common_callback(self, ldap, dn, entry_attrs, *keys, **options):
     assert isinstance(dn, DN)
     self.preserve_krbprincipalname_post(ldap, entry_attrs, **options)
     if options.get('random', False):
         try:
             entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
         except AttributeError:
             # if both randompassword and userpassword options were used
             pass
     convert_nsaccountlock(entry_attrs)
     self.obj.get_password_attributes(ldap, dn, entry_attrs)
     self.obj.convert_usercertificate_post(entry_attrs, **options)
     convert_sshpubkey_post(entry_attrs)
     remove_sshpubkey_from_output_post(self.context, entry_attrs)
     radius_dn2pk(self.api, entry_attrs)
Ejemplo n.º 17
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        exc = None
        if dns_container_exists(ldap):
            try:
                parts = keys[-1].split('.')
                host = parts[0]
                domain = unicode('.'.join(parts[1:]))

                if options.get('ip_address'):
                    add_reverse = not options.get('no_reverse', False)

                    add_records_for_host(DNSName(host),
                                         DNSName(domain).make_absolute(),
                                         options['ip_address'],
                                         add_forward=True,
                                         add_reverse=add_reverse)
                    del options['ip_address']

                update_sshfp_record(domain, unicode(parts[0]), entry_attrs)
            except Exception as e:
                exc = e
        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
            except AttributeError:
                # On the off-chance some other extension deletes this from the
                # context, don't crash.
                pass
        if exc:
            raise errors.NonFatalError(
                reason=_('The host was added but the DNS update failed with: %(exc)s') % dict(exc=exc)
            )
        set_certificate_attrs(entry_attrs)
        set_kerberos_attrs(entry_attrs, options)
        rename_ipaallowedtoperform_from_ldap(entry_attrs, options)

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        convert_sshpubkey_post(ldap, dn, entry_attrs)

        return dn
Ejemplo n.º 18
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        exc = None
        if dns_container_exists(ldap):
            try:
                parts = keys[-1].split('.')
                host = parts[0]
                domain = unicode('.'.join(parts[1:]))

                if options.get('ip_address'):
                    add_reverse = not options.get('no_reverse', False)

                    add_records_for_host(DNSName(host),
                                         DNSName(domain).make_absolute(),
                                         options['ip_address'],
                                         add_forward=True,
                                         add_reverse=add_reverse)
                    del options['ip_address']

                update_sshfp_record(domain, unicode(parts[0]), entry_attrs)
            except Exception as e:
                exc = e
        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
            except AttributeError:
                # On the off-chance some other extension deletes this from the
                # context, don't crash.
                pass
        if exc:
            raise errors.NonFatalError(
                reason=_('The host was added but the DNS update failed with: %(exc)s') % dict(exc=exc)
            )
        set_certificate_attrs(entry_attrs)
        set_kerberos_attrs(entry_attrs, options)
        rename_ipaallowedtoperform_from_ldap(entry_attrs, options)

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        convert_sshpubkey_post(ldap, dn, entry_attrs)

        return dn
Ejemplo n.º 19
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        set_certificate_attrs(entry_attrs)

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)

        self.obj.suppress_netgroup_memberof(ldap, entry_attrs)

        convert_sshpubkey_post(ldap, dn, entry_attrs)

        return dn
Ejemplo n.º 20
0
    def post_callback(self, ldap, entries, truncated, *args, **options):
        if options.get('pkey_only', False):
            return truncated
        for entry_attrs in entries:
            set_certificate_attrs(entry_attrs)
            set_kerberos_attrs(entry_attrs, options)
            rename_ipaallowedtoperform_from_ldap(entry_attrs, options)
            self.obj.suppress_netgroup_memberof(ldap, entry_attrs)

            if options.get('all', False):
                entry_attrs['managing'] = self.obj.get_managed_hosts(entry_attrs.dn)

            convert_sshpubkey_post(entry_attrs)
            remove_sshpubkey_from_output_post(self.context, entry_attrs)
            convert_ipaassignedidview_post(entry_attrs, options)

        remove_sshpubkey_from_output_list_post(self.context, entries)

        return truncated
Ejemplo n.º 21
0
    def post_callback(self, ldap, entries, truncated, *args, **options):
        if options.get('pkey_only', False):
            return truncated
        for entry in entries:
            (dn, entry_attrs) = entry
            set_certificate_attrs(entry_attrs)
            self.obj.get_password_attributes(ldap, dn, entry_attrs)
            self.obj.suppress_netgroup_memberof(ldap, entry_attrs)
            if entry_attrs['has_password']:
                # If an OTP is set there is no keytab, at least not one
                # fetched anywhere.
                entry_attrs['has_keytab'] = False

            if options.get('all', False):
                entry_attrs['managing'] = self.obj.get_managed_hosts(entry[0])

            convert_sshpubkey_post(ldap, dn, entry_attrs)

        return truncated
Ejemplo n.º 22
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        set_certificate_attrs(entry_attrs)
        set_kerberos_attrs(entry_attrs, options)

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)

        self.obj.suppress_netgroup_memberof(ldap, entry_attrs)

        convert_sshpubkey_post(ldap, dn, entry_attrs)

        return dn
Ejemplo n.º 23
0
    def post_callback(self, ldap, entries, truncated, *args, **options):
        if options.get('pkey_only', False):
            return truncated
        for entry in entries:
            (dn, entry_attrs) = entry
            set_certificate_attrs(entry_attrs)
            set_kerberos_attrs(entry_attrs, options)
            self.obj.get_password_attributes(ldap, dn, entry_attrs)
            self.obj.suppress_netgroup_memberof(ldap, entry_attrs)
            if entry_attrs['has_password']:
                # If an OTP is set there is no keytab, at least not one
                # fetched anywhere.
                entry_attrs['has_keytab'] = False

            if options.get('all', False):
                entry_attrs['managing'] = self.obj.get_managed_hosts(entry[0])

            convert_sshpubkey_post(ldap, dn, entry_attrs)

        return truncated
Ejemplo n.º 24
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        config = ldap.get_ipa_config()

        # Fetch the entry again to update memberof, mep data, etc updated
        # at the end of the transaction.
        newentry = ldap.get_entry(dn, ['*'])
        entry_attrs.update(newentry)

        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
            except AttributeError:
                # if both randompassword and userpassword options were used
                pass

        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        convert_sshpubkey_post(ldap, dn, entry_attrs)
        radius_dn2pk(self.api, entry_attrs)
        return dn
Ejemplo n.º 25
0
    def post_callback(self, ldap, entries, truncated, *args, **options):
        if options.get('pkey_only', False):
            return truncated
        for entry_attrs in entries:
            set_certificate_attrs(entry_attrs)
            set_kerberos_attrs(entry_attrs, options)
            rename_ipaallowedtoperform_from_ldap(entry_attrs, options)
            self.obj.get_password_attributes(ldap, entry_attrs.dn, entry_attrs)
            self.obj.suppress_netgroup_memberof(ldap, entry_attrs)
            if entry_attrs['has_password']:
                # If an OTP is set there is no keytab, at least not one
                # fetched anywhere.
                entry_attrs['has_keytab'] = False

            if options.get('all', False):
                entry_attrs['managing'] = self.obj.get_managed_hosts(entry_attrs.dn)

            convert_sshpubkey_post(ldap, entry_attrs.dn, entry_attrs)
            convert_ipaassignedidview_post(entry_attrs, options)

        return truncated
Ejemplo n.º 26
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        config = ldap.get_ipa_config()

        # Fetch the entry again to update memberof, mep data, etc updated
        # at the end of the transaction.
        newentry = ldap.get_entry(dn, ['*'])
        entry_attrs.update(newentry)

        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(
                    getattr(context, 'randompassword'))
            except AttributeError:
                # if both randompassword and userpassword options were used
                pass

        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        convert_sshpubkey_post(ldap, dn, entry_attrs)
        radius_dn2pk(self.api, entry_attrs)
        return dn
Ejemplo n.º 27
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        if options.get('random', False):
            entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
        set_certificate_attrs(entry_attrs)
        set_kerberos_attrs(entry_attrs, options)
        rename_ipaallowedtoperform_from_ldap(entry_attrs, options)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)

        self.obj.suppress_netgroup_memberof(ldap, entry_attrs)

        convert_sshpubkey_post(ldap, dn, entry_attrs)
        convert_ipaassignedidview_post(entry_attrs, options)

        return dn
Ejemplo n.º 28
0
    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        if options.get('random', False):
            entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
        set_certificate_attrs(entry_attrs)
        set_kerberos_attrs(entry_attrs, options)
        rename_ipaallowedtoperform_from_ldap(entry_attrs, options)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)

        self.obj.suppress_netgroup_memberof(ldap, entry_attrs)

        convert_sshpubkey_post(ldap, dn, entry_attrs)
        convert_ipaassignedidview_post(entry_attrs, options)

        return dn
Ejemplo n.º 29
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     dn = super(idoverrideuser_show, self).post_callback(ldap, dn,
              entry_attrs, *keys, **options)
     convert_sshpubkey_post(entry_attrs)
     self.obj.convert_usercertificate_post(entry_attrs, **options)
     return dn
Ejemplo n.º 30
0
class host_add(LDAPCreate):
    __doc__ = _('Add a new host.')

    has_output_params = LDAPCreate.has_output_params + host_output_params
    msg_summary = _('Added host "%(value)s"')
    member_attributes = ['managedby']
    takes_options = LDAPCreate.takes_options + (
        Flag('force',
            label=_('Force'),
            doc=_('force host name even if not in DNS'),
        ),
        Flag('no_reverse',
            doc=_('skip reverse DNS detection'),
        ),
        Str('ip_address?', validate_ipaddr,
            doc=_('Add the host to DNS with this IP address'),
            label=_('IP Address'),
        ),
    )

    def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
        assert isinstance(dn, DN)
        if options.get('ip_address') and dns_container_exists(ldap):
            parts = keys[-1].split('.')
            host = parts[0]
            domain = unicode('.'.join(parts[1:]))
            check_reverse = not options.get('no_reverse', False)
            add_records_for_host_validation('ip_address', host, domain,
                    options['ip_address'],
                    check_forward=True,
                    check_reverse=check_reverse)
        if not options.get('force', False) and not 'ip_address' in options:
            util.validate_host_dns(self.log, keys[-1])
        if 'locality' in entry_attrs:
            entry_attrs['l'] = entry_attrs['locality']
            del entry_attrs['locality']
        entry_attrs['cn'] = keys[-1]
        entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0]
        if 'userpassword' not in entry_attrs and not options.get('random', False):
            entry_attrs['krbprincipalname'] = 'host/%s@%s' % (
                keys[-1], self.api.env.realm
            )
            if 'krbprincipalaux' not in entry_attrs['objectclass']:
                entry_attrs['objectclass'].append('krbprincipalaux')
            if 'krbprincipal' not in entry_attrs['objectclass']:
                entry_attrs['objectclass'].append('krbprincipal')
        else:
            if 'krbprincipalaux' in entry_attrs['objectclass']:
                entry_attrs['objectclass'].remove('krbprincipalaux')
            if 'krbprincipal' in entry_attrs['objectclass']:
                entry_attrs['objectclass'].remove('krbprincipal')
        if options.get('random'):
            entry_attrs['userpassword'] = ipa_generate_password(characters=host_pwd_chars)
            # save the password so it can be displayed in post_callback
            setattr(context, 'randompassword', entry_attrs['userpassword'])
        cert = options.get('usercertificate')
        if cert:
            cert = x509.normalize_certificate(cert)
            x509.verify_cert_subject(ldap, keys[-1], cert)
            entry_attrs['usercertificate'] = cert
        entry_attrs['managedby'] = dn
        entry_attrs['objectclass'].append('ieee802device')
        entry_attrs['objectclass'].append('ipasshhost')
        return dn

    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
        assert isinstance(dn, DN)
        exc = None
        if dns_container_exists(ldap):
            try:
                parts = keys[-1].split('.')
                host = parts[0]
                domain = unicode('.'.join(parts[1:]))

                if options.get('ip_address'):
                    add_reverse = not options.get('no_reverse', False)

                    add_records_for_host(host, domain, options['ip_address'],
                                         add_forward=True,
                                         add_reverse=add_reverse)
                    del options['ip_address']

                update_sshfp_record(domain, unicode(parts[0]), entry_attrs)
            except Exception, e:
                exc = e
        if options.get('random', False):
            try:
                entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword'))
            except AttributeError:
                # On the off-chance some other extension deletes this from the
                # context, don't crash.
                pass
        if exc:
            raise errors.NonFatalError(
                reason=_('The host was added but the DNS update failed with: %(exc)s') % dict(exc=exc)
            )
        set_certificate_attrs(entry_attrs)

        if options.get('all', False):
            entry_attrs['managing'] = self.obj.get_managed_hosts(dn)
        self.obj.get_password_attributes(ldap, dn, entry_attrs)
        if entry_attrs['has_password']:
            # If an OTP is set there is no keytab, at least not one
            # fetched anywhere.
            entry_attrs['has_keytab'] = False

        convert_sshpubkey_post(ldap, dn, entry_attrs)

        return dn
Ejemplo n.º 31
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     dn = super(idoverrideuser_add,
                self).post_callback(ldap, dn, entry_attrs, *keys, **options)
     convert_sshpubkey_post(ldap, dn, entry_attrs)
     return dn
Ejemplo n.º 32
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     dn = super(idoverrideuser_mod, self).post_callback(ldap, dn,
              entry_attrs, *keys, **options)
     convert_sshpubkey_post(ldap, dn, entry_attrs)
     return dn
Ejemplo n.º 33
0
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
     dn = super(idoverrideuser_show, self).post_callback(ldap, dn,
              entry_attrs, *keys, **options)
     convert_sshpubkey_post(entry_attrs)
     self.obj.convert_usercertificate_post(entry_attrs, **options)
     return dn