示例#1
0
def handler(dn, new, old):
    if is_special_ucsschool_group(dn):
        update_local_school_list()

    univention.debug.debug(univention.debug.LISTENER, univention.debug.PROCESS,
                           'pupilgroups: dn: %s' % dn)
    configRegistry = univention.config_registry.ConfigRegistry()
    configRegistry.load()
    if all_local_schools is None:
        univention.debug.debug(univention.debug.LISTENER,
                               univention.debug.ERROR,
                               'pupilgroups: Could not detect local schools')
    elif not any(dn.lower().endswith(',cn=groups,%s' % school.lower())
                 for school in all_local_schools):
        univention.debug.debug(
            univention.debug.LISTENER, univention.debug.INFO,
            'pupilgroups: dn: %s does not belong to local schools %r' %
            (dn, all_local_schools))
        return  # the object doesn't belong to this school

    changes = {}
    if new and new.get('memberUid'):
        changes[keyPattern % new['cn'][0]] = ','.join(new.get('memberUid', []))
    elif old:  # old lost its last memberUid OR old was removed
        changes[keyPattern % old['cn'][0]] = None
    univention.debug.debug(univention.debug.LISTENER, univention.debug.INFO,
                           'pupilgroups: %r' % (changes, ))

    listener.setuid(0)
    try:
        ucr_update(configRegistry, changes)
    finally:
        listener.unsetuid()
示例#2
0
def ucr_save(values):
    changed_values = {}
    _UCR.load()
    for k, v in values.iteritems():
        if _UCR.get(k) != v:
            changed_values[k] = v
    if changed_values:
        ucr_update(_UCR, changed_values)
    def commit(self):
        '''
		Saves UCR variables previously set by set_ucr_var(). Also commits
		changes (if done any). Is called automatically *if inner_run() did not
		raise an exception*. You can call it manually if you need to
		do it (e.g. in down()).
		'''
        if self.changes:
            ucr_update(self.ucr, self.changes)
            # reset (in case it is called multiple) times in a script
            self.changes.clear()
示例#4
0
	def set_ucs_overview_link(cls):
		from univention.config_registry import ConfigRegistry
		ucr = ConfigRegistry()
		ucr.load()

		sp_query_string = "?spentityid=urn:federation:MicrosoftOnline"
		sp_link = "https://{}/simplesamlphp/saml2/idp/SSOService.php{}".format(ucr["ucs/server/sso/fqdn"], sp_query_string)
		ucr_update(ucr, {
			"ucs/web/overview/entries/service/office365/description": "Single Sign-On login for Microsoft Office 365",
			"ucs/web/overview/entries/service/office365/label": "Office 365 Login",
			"ucs/web/overview/entries/service/office365/link": sp_link,
			"ucs/web/overview/entries/service/office365/description/de": "Single-Sign-On Link für Microsoft Office 365",
			"ucs/web/overview/entries/service/office365/label/de": "Office 365 Login",
			"ucs/web/overview/entries/service/office365/priority": "50",
			"ucs/web/overview/entries/service/office365/icon": "/office365.png"
		})
def main() -> None:
	def get_role() -> Optional[str]:
		return configRegistry.get('server/role', None)

	def get_users() -> Optional[int]:
		if get_role() != 'domaincontroller_master':
			return None
		lo, _ = getReadonlyAdminConnection()
		filter = _license.filters['2'][_license.USERS]
		return len(lo.searchDn(filter=filter))

	configRegistry = ConfigRegistry()
	configRegistry.load()
	ucr_update(
		configRegistry,
		{
			'updater/statistics': encode_additional_info(users=get_users(), role=get_role()),
		}
	)
示例#6
0
def prepare_setup_BB_API():
	ucr = ConfigRegistry()
	ucr.load()
	ucr_update(ucr, {
		'bb/http_api/users/django_debug': 'yes',
		'bb/http_api/users/wsgi_server_capture_output': 'yes',
		'bb/http_api/users/wsgi_server_loglevel': 'debug',
		'bb/http_api/users/enable_session_authentication': 'yes',
	})
	shutil.copyfile(
		'/usr/share/ucs-school-import/configs/ucs-school-testuser-http-import.json',
		'/var/lib/ucs-school-import/configs/user_import.json'
	)
	with open('/var/lib/ucs-school-import/configs/user_import.json', 'r+w') as fp:
		config = json.load(fp)
		config['configuration_checks'] = ['defaults', 'mapped_udm_properties']
		config['mapped_udm_properties'] = ['phone', 'e-mail', 'organisation']
		fp.seek(0)
		json.dump(config, fp, indent=4, sort_keys=True)
	with open('/etc/apt/sources.list.d/30_BB.list', 'w') as fp:
		fp.write('deb [trusted=yes] http://192.168.0.10/build2/ ucs_4.4-0-min-brandenburg/all/\n')
		fp.write('deb [trusted=yes] http://192.168.0.10/build2/ ucs_4.4-0-min-brandenburg/amd64/')
示例#7
0
 def commit(self):
     ucr_update(self.ucr, self._changes)
示例#8
0
	def test_ucr_update(self, ucrf, run, mocker):
		ucrfe.ucr_update(ucrf, self.CHANGES)
		run.assert_called_once_with(mocker.ANY, self.CHANGED)