def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) # Since external_post_callback returns the total number of completed # entries yet (that is, any external users it added plus the value of # passed variable 'completed', we need to pass 0 as completed, # so that the entries added by the framework are not counted twice # (once in each call of remove_external_post_callback) (completed_ex_users, dn) = remove_external_post_callback(ldap, dn, entry_attrs=entry_attrs, failed=failed, completed=0, memberattr='ipasudorunas', membertype='user', externalattr='ipasudorunasextuser', ) (completed_ex_groups, dn) = remove_external_post_callback(ldap, dn, entry_attrs=entry_attrs, failed=failed, completed=0, memberattr='ipasudorunas', membertype='group', externalattr='ipasudorunasextusergroup', ) return (completed + completed_ex_users + completed_ex_groups, dn)
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) try: _entry_attrs = ldap.get_entry(dn, self.obj.default_attributes) except errors.NotFound: self.obj.handle_not_found(*keys) if 'hostmask' in options: def norm(x): return unicode(netaddr.IPNetwork(x).cidr) old_masks = set(norm(m) for m in _entry_attrs.get('hostmask', [])) removed_masks = set(norm(m) for m in options['hostmask']) num_added = len(removed_masks & old_masks) if num_added: entry_attrs['hostmask'] = list(old_masks - removed_masks) try: ldap.update_entry(entry_attrs) except errors.EmptyModlist: pass completed = completed + num_added return remove_external_post_callback(ldap, dn, entry_attrs, failed=failed, completed=completed, memberattr='memberhost', membertype='host', externalattr='externalhost')
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) try: _entry_attrs = ldap.get_entry(dn, self.obj.default_attributes) except errors.NotFound: self.obj.handle_not_found(*keys) if 'hostmask' in options: norm = lambda x: unicode(netaddr.IPNetwork(x).cidr) old_masks = set(map(norm, _entry_attrs.get('hostmask', []))) removed_masks = set(map(norm, options['hostmask'])) num_added = len(removed_masks & old_masks) if num_added: entry_attrs['hostmask'] = list(old_masks - removed_masks) try: ldap.update_entry(entry_attrs) except errors.EmptyModlist: pass completed = completed + num_added return remove_external_post_callback(ldap, dn, entry_attrs, failed=failed, completed=completed, memberattr='memberhost', membertype='host', externalattr='externalhost')
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) return remove_external_post_callback(ldap, dn, entry_attrs, failed=failed, completed=completed, memberattr='memberuser', membertype='user', externalattr='externaluser')
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) return remove_external_post_callback(ldap, dn, entry_attrs, failed=failed, completed=completed, memberattr='ipasudorunasgroup', membertype='group', externalattr='ipasudorunasextgroup', )
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) result = (completed, dn) if 'ipaexternalmember' in options: if not _dcerpc_bindings_installed: raise errors.NotFound(reason=_('Cannot perform external member validation without ' 'Samba 4 support installed. Make sure you have installed ' 'server-trust-ad sub-package of IPA on the server')) domain_validator = ipaserver.dcerpc.DomainValidator(self.api) if not domain_validator.is_configured(): raise errors.NotFound(reason=_('Cannot perform join operation without own domain configured. ' 'Make sure you have run ipa-adtrust-install on the IPA server first')) sids = [] failed_sids = [] for sid in options['ipaexternalmember']: if domain_validator.is_trusted_sid_valid(sid): sids.append(sid) else: try: actual_sid = domain_validator.get_trusted_domain_object_sid(sid) except errors.PublicError as e: failed_sids.append((sid, unicode(e))) else: sids.append(actual_sid) restore = [] if 'member' in failed and 'group' in failed['member']: restore = failed['member']['group'] failed['member']['group'] = list((id, id) for id in sids) result = remove_external_post_callback(ldap, dn, entry_attrs, failed=failed, completed=completed, memberattr='member', membertype='group', externalattr='ipaexternalmember', ) failed['member']['group'] += restore + failed_sids return result