ucsschool.lib package#
Subpackages#
- ucsschool.lib.models package
- Submodules
- ucsschool.lib.models.attributes module
ValidationErrorAttributeCommonNameis_valid_win_directory_name()UsernameDHCPServerNameDHCPServiceNameGroupNameSchoolClassNameShareNameSubnetNameDHCPSubnetNameSchoolNameDCNameFirstnameLastnameBirthdayUserExpirationDateEmailPasswordDisabledSchoolAttributeSchoolClassesAttributeSchoolClassAttributeWorkgroupAttributeWorkgroupsAttributeDescriptionDisplayNameEmptyAttributesContainerPathShareFileServerGroupsUsersIPAddressSubnetMaskDHCPSubnetMaskDHCPServiceAttributeBroadcastAddressNetworkBroadcastAddressNetworkAttributeNetmaskMACAddressInventoryNumberHostsSchoolsRecordUIDSourceUIDRolesSyntaxRoles
- ucsschool.lib.models.base module
NoObjectUnknownModelWrongModelWrongObjectTypeMultipleObjectsErrorUCSSchoolHelperAbstractClassUCSSchoolHelperAbstractClass.hook_sep_charUCSSchoolHelperAbstractClass.nameUCSSchoolHelperAbstractClass.schoolUCSSchoolHelperAbstractClass.cache()UCSSchoolHelperAbstractClass.invalidate_all_caches()UCSSchoolHelperAbstractClass.invalidate_cache()UCSSchoolHelperAbstractClass.supports_school()UCSSchoolHelperAbstractClass.supports_schools()UCSSchoolHelperAbstractClass.get_machine_connection()UCSSchoolHelperAbstractClass.positionUCSSchoolHelperAbstractClass.dnUCSSchoolHelperAbstractClass.set_attributes()UCSSchoolHelperAbstractClass.set_dn()UCSSchoolHelperAbstractClass.validate()UCSSchoolHelperAbstractClass.validate_roles()UCSSchoolHelperAbstractClass.add_warning()UCSSchoolHelperAbstractClass.add_error()UCSSchoolHelperAbstractClass.exists()UCSSchoolHelperAbstractClass.exists_outside_school()UCSSchoolHelperAbstractClass.call_hooks()UCSSchoolHelperAbstractClass.hook_init()UCSSchoolHelperAbstractClass.create()UCSSchoolHelperAbstractClass.create_without_hooks()UCSSchoolHelperAbstractClass.create_without_hooks_roles()UCSSchoolHelperAbstractClass.do_create()UCSSchoolHelperAbstractClass.modify()UCSSchoolHelperAbstractClass.modify_without_hooks()UCSSchoolHelperAbstractClass.modify_without_hooks_roles()UCSSchoolHelperAbstractClass.update_ucsschool_roles()UCSSchoolHelperAbstractClass.do_modify()UCSSchoolHelperAbstractClass.move()UCSSchoolHelperAbstractClass.move_without_hooks()UCSSchoolHelperAbstractClass.do_move()UCSSchoolHelperAbstractClass.do_move_roles()UCSSchoolHelperAbstractClass.change_school()UCSSchoolHelperAbstractClass.do_school_change()UCSSchoolHelperAbstractClass.remove()UCSSchoolHelperAbstractClass.remove_without_hooks()UCSSchoolHelperAbstractClass.get_name_from_dn()UCSSchoolHelperAbstractClass.get_school_from_dn()UCSSchoolHelperAbstractClass.find_field_label_from_name()UCSSchoolHelperAbstractClass.get_error_msg()UCSSchoolHelperAbstractClass.get_warning_msg()UCSSchoolHelperAbstractClass.create_validation_msg()UCSSchoolHelperAbstractClass.get_udm_object()UCSSchoolHelperAbstractClass.get_school_obj()UCSSchoolHelperAbstractClass.get_superordinate()UCSSchoolHelperAbstractClass.get_own_container()UCSSchoolHelperAbstractClass.get_container()UCSSchoolHelperAbstractClass.get_search_base()UCSSchoolHelperAbstractClass.init_udm_module()UCSSchoolHelperAbstractClass.get_all()UCSSchoolHelperAbstractClass.lookup()UCSSchoolHelperAbstractClass.build_easy_filter()UCSSchoolHelperAbstractClass.from_udm_obj()UCSSchoolHelperAbstractClass.get_class_for_udm_obj()UCSSchoolHelperAbstractClass.from_dn()UCSSchoolHelperAbstractClass.get_only_udm_obj()UCSSchoolHelperAbstractClass.get_first_udm_obj()UCSSchoolHelperAbstractClass.find_udm_superordinate()UCSSchoolHelperAbstractClass.to_dict()UCSSchoolHelperAbstractClass.logger
RoleSupportMixinRoleSupportMixin.ucsschool_rolesRoleSupportMixin.default_rolesRoleSupportMixin.get_schools()RoleSupportMixin.get_schools_from_udm_obj()RoleSupportMixin.roles_as_dictsRoleSupportMixin.do_move_roles()RoleSupportMixin.validate_roles()RoleSupportMixin.create_without_hooks_roles()RoleSupportMixin.update_ucsschool_roles()
- ucsschool.lib.models.computer module
AnyComputerSchoolDCSchoolDCSlaveSchoolComputerSchoolComputer.ip_addressSchoolComputer.subnet_maskSchoolComputer.mac_addressSchoolComputer.inventory_numberSchoolComputer.zoneSchoolComputer.type_nameSchoolComputer.DEFAULT_PREFIX_LENSchoolComputer.lookup()SchoolComputer.get_inventory_numbers()SchoolComputer.teacher_computerSchoolComputer.get_container()SchoolComputer.create()SchoolComputer.create_without_hooks()SchoolComputer.modify_without_hooks()SchoolComputer.get_ipv4_network()SchoolComputer.get_network()SchoolComputer.create_network()SchoolComputer.validate()SchoolComputer.get_class_for_udm_obj()SchoolComputer.from_udm_obj()SchoolComputer.to_dict()SchoolComputer.MetaSchoolComputer.logger
WindowsComputerMacComputerIPComputerUbuntuComputerLinuxComputer
- ucsschool.lib.models.dhcp module
- ucsschool.lib.models.group module
EmailAttributesMixinGroupGroup.nameGroup.descriptionGroup.usersGroup.get_container()Group.is_school_group()Group.is_school_workgroup()Group.is_school_class()Group.is_computer_room()Group.self_is_workgroup()Group.self_is_class()Group.self_is_computerroom()Group.get_class_for_udm_obj()Group.add_umc_policy()Group.MetaGroup.logger
BasicGroupBasicSchoolGroupSchoolGroupSchoolClassSchoolClass.nameSchoolClass.default_rolesSchoolClass.ShareClassSchoolClass.create_without_hooks()SchoolClass.create_share()SchoolClass.modify_without_hooks()SchoolClass.remove_without_hooks()SchoolClass.get_container()SchoolClass.to_dict()SchoolClass.get_class_for_udm_obj()SchoolClass.hook_init()SchoolClass.validate()SchoolClass.logger
WorkGroupComputerRoom
- ucsschool.lib.models.hook module
- ucsschool.lib.models.meta module
- ucsschool.lib.models.misc module
- ucsschool.lib.models.network module
- ucsschool.lib.models.policy module
- ucsschool.lib.models.school module
SchoolSchool.nameSchool.dc_nameSchool.dc_name_administrativeSchool.class_share_file_serverSchool.home_share_file_serverSchool.schoolSchool.educational_serversSchool.administrative_serversSchool.default_rolesSchool.display_nameSchool.validate()School.get_district()School.get_own_container()School.get_container()School.cn_name()School.create_default_containers()School.group_name()School.get_umc_policy_dn()School.create_default_groups()School.get_dc_name_fallback()School.get_dc_name()School.get_share_fileserver_dn()School.get_class_share_file_server()School.get_home_share_file_server()School.get_administrative_group_name()School.get_administrative_server_names()School.get_educational_server_names()School.add_host_to_dc_group()School.shall_create_administrative_objects()School.create_dc_slave()School.add_domain_controllers()School.get_dhcp_service()School.create_without_hooks()School.remove_without_hooks()School.get_schools()School.from_binddn()School.from_udm_obj()School.get_all()School.invalidate_cache()School.set_ucsschool_role_for_dc()School.create_market_place_share()School.create_dhcp_search_base()School.create_dhcp_dns_policy()School.create_import_group()School.create_exam_group()School.MetaSchool.logger
- ucsschool.lib.models.share module
NoSIDNoSchoolGroupSetNTACLsMixinSetNTACLsMixin.get_nt_acls()SetNTACLsMixin.get_groups_samba_sid()SetNTACLsMixin.get_ou_admin_full_control()SetNTACLsMixin.get_aces_deny_students_change_permissions()SetNTACLsMixin.get_aces_work_group()SetNTACLsMixin.get_aces_market_place()SetNTACLsMixin.get_aces_class_group()SetNTACLsMixin.set_nt_acls()
ShareGroupShareWorkGroupShareClassShareMarketplaceShare
- ucsschool.lib.models.user module
UserUser.nameUser.schoolsUser.firstnameUser.lastnameUser.birthdayUser.expiration_dateUser.emailUser.passwordUser.disabledUser.workgroupsUser.type_nameUser.type_filterUser.rolesUser.default_rolesUser.default_optionsUser.school_classesUser.shall_create_mail_domain()User.get_roleshare_home_subdir()User.get_samba_home_drive()User.get_samba_netlogon_script_path()User.get_samba_home_path()User.get_profile_path()User.is_student()User.is_exam_student()User.is_teacher()User.is_staff()User.is_administrator()User.get_class_for_udm_obj()User.from_udm_obj()User.create()User.do_create()User.modify()User.do_modify()User.do_school_change()User.get_mail_domain()User.create_mail_domain()User.set_default_options()User.get_default_options()User.get_specific_groups()User.validate()User.remove_from_school()User.remove_from_groups_of_school()User.get_group_dn()User.get_class_dn()User.get_workgroup_dn()User.primary_group_dn()User.get_domain_users_groups()User.get_students_groups()User.get_teachers_groups()User.get_staff_groups()User.get_school_admin_groups()User.groups_used()User.get_or_create_group_udm_object()User.is_active()User.to_dict()User.get_school_class_objs()User.get_workgroup_objs()User.get_school_classes()User.get_workgroups()User.get_container()User.lookup()User.MetaUser.logger
StudentTeacherSchoolAdminStaffStaff.school_classesStaff.type_nameStaff.rolesStaff.default_rolesStaff.type_filterStaff.default_optionsStaff.get_container()Staff.get_samba_home_path()Staff.get_samba_home_drive()Staff.get_samba_netlogon_script_path()Staff.get_profile_path()Staff.get_school_class_objs()Staff.get_school_classes()Staff.get_specific_groups()Staff.logger
TeachersAndStaffExamStudent
- ucsschool.lib.models.utils module
NotInstalledUnknownPackageValidationDataFiltermkdir_p()UniFileHandlerUniStreamHandlerModuleHandlerUCSTTYColoredFormatteradd_stream_logger_to_schoollib()add_module_logger_to_schoollib()create_passwd()flatten()loglevel_int2str()nearest_known_loglevel()get_stream_handler()get_file_handler()get_logger()exec_cmd()stopped_notifier()get_package_version()add_or_remove_ucrv_value()
- ucsschool.lib.models.validator module
get_private_data_logger()get_position_from()obj_to_dict()obj_to_dict_conversion()is_student_role()SchoolValidatorSchoolValidator.position_regexSchoolValidator.attributesSchoolValidator.rolesSchoolValidator.validate()SchoolValidator.required_attributes()SchoolValidator.position()SchoolValidator.required_roles()SchoolValidator.roles_at_school()SchoolValidator.expected_roles()SchoolValidator.get_search_base()
UserValidatorUserValidator.is_studentUserValidator.is_exam_userUserValidator.is_teacherUserValidator.is_staffUserValidator.is_school_adminUserValidator.attributesUserValidator.validate()UserValidator.expected_roles()UserValidator.expected_groups()UserValidator.validate_required_groups()UserValidator.validate_part_of_school()UserValidator.validate_student_roles()UserValidator.domain_users_group()UserValidator.role_groups()UserValidator.validate_group_membership()
StudentValidatorTeacherValidatorExamStudentValidatorStaffValidatorTeachersAndStaffValidatorSchoolAdminValidatorGroupAndShareValidatorSchoolClassValidatorWorkGroupValidatorComputerroomValidatorWorkGroupShareValidatorClassShareValidatorMarketplaceShareValidatorget_class()validate()
- ucsschool.lib.pyhooks package
Submodules#
ucsschool.lib.consistency module#
This module check the constistency of USC@school users, shares and groups
- class ucsschool.lib.consistency.UserCheck[source]#
Bases:
object- check_allowed_membership(group_dn: str, students: bool | None = False, teachers: bool | None = False, staff: bool | None = False) List[str][source]#
This function is used to check if a group of a user matches the users UCS@school role(s). The caller specifies the group dn and the user roles which are allowed by setting them to ‘True’. Example: ‘group_dn’ is expected to be a teachers group, i.e. ‘teachers’ is set to True by the caller. If the group turns out to be a students group (where teachers are disallowed) and ‘students’ is False, it is an error. A warning will be appended to a list which will be returned.
- ucsschool.lib.consistency.check_mandatory_groups_exist(school: str = None) Dict[str, List[str]][source]#
ucsschool.lib.create_ou module#
Class to create an OU. Used by create_ou script and customer single user HTTP API.
- ucsschool.lib.create_ou.create_ou(ou_name, display_name, edu_name, admin_name, share_name, lo, baseDN, hostname, is_single_master, alter_dhcpd_base=None)[source]#
Create a ucsschool OU.
- Parameters:
ou_name (str) – name for the OU, see models.attributes::SchoolName for allowed values, may contain dashes and underscores, but the latter only if DC name(s) are passed explicitly (without underscore), max length is 11 chars if DC names are not passed explicitly.
display_name (str) – display name for the OU
edu_name (str) – host name of educational school server, see models.attributes::DCName for allowed values, may contain dashes but no underscores, max 13 chars
admin_name (str) – host name of administrative school server, see models.attributes::DCName for allowed values, may contain dashes but no underscores, max 13 chars
share_name (str) – host name
lo (univention.uldap.access) – LDAP connection object
baseDN (str) – base DN
hostname (str) – hostname of Primary Directory Node in case of singleserver
is_single_master (bool) – whether it is a singleserver
alter_dhcpd_base (bool) – if the DHCP base should be modified
- Return bool:
whether the OU was sucessfully created (or already existed)
- Raises:
ValueError – on validation errors
ucsschool.lib.i18n module#
- ucsschool.lib.i18n.ucs_school_name_i18n(name, lang='de')[source]#
i18n function for localization of UCS@school standard names
ucsschool.lib.info module#
- class ucsschool.lib.info.MembershipFlags(is_edu_school_member, is_admin_school_member)#
Bases:
tupleCreate new instance of MembershipFlags(is_edu_school_member, is_admin_school_member)
- is_admin_school_member#
Alias for field number 1
- is_edu_school_member#
Alias for field number 0
- ucsschool.lib.info.get_school_membership_type(lo: univention.uldap.access, dn: str) MembershipFlags[source]#
Returns a named tuple, that states if the given computer object specified by dn is an educational school Replica Directory Node/Managed Node or administrative Replica Directory Node/Managed Node.
- Parameters:
lo (univention.uldap.access) – the LDAP connection
dn (str) – DN of the computer object
- Returns:
a named tuple that contains flags for educational and administrative membership
- Return type:
namedtuple(is_edu_school_member, is_admin_school_member)
- ucsschool.lib.info.is_central_computer(lo: univention.uldap.access, dn: str) bool[source]#
Checks if the given computer object specified by dn is a central system or located at a specific school.
- Parameters:
lo (univention.uldap.access) – the LDAP connection
dn (str) – DN of the computer object
- Returns:
is the computer a central system?
- Return type:
- ucsschool.lib.info.is_school_slave(lo: univention.uldap.access, dn: str) bool[source]#
Checks if the given domaincontroller_slave object (specified by dn) is a school Replica Node.
- Parameters:
lo (univention.uldap.access) – the LDAP connection
dn (str) – DN of the computer object
- Returns:
is the computer a school Replica Directory Node?
- Return type:
- Raises:
ValueError – computer DN does not refer to a computers/domaincontroller_slave object
ucsschool.lib.internetrules module#
- class ucsschool.lib.internetrules.Rule(name, type=0, priority=0, wlan=False, domains=[], userRule=False)[source]#
Bases:
object- property domains#
Return list of all domains, the order respects the indeces. Show only the entries that match the current filter type.
- ucsschool.lib.internetrules.findUCRVariables(filterName=None, userRule=False)[source]#
Returns a dict of all UCR variables or all variables matching the specified rule name.
- ucsschool.lib.internetrules.remove(name, userRule=False)[source]#
Removes the UCR variables corresponding to the specified rule.
- ucsschool.lib.internetrules.list(filterName=None, userRule=False)[source]#
Returns a list of all existing rules. If name is given, returns only the rule matching the specified name or None. userRule specifies whether all common rules (=False) or only user-specific rules (=True) are listed. If filterName is specified, only rule matching this name is returned as single object (not as list!).
- ucsschool.lib.internetrules.getGroupRuleName(groupNames)[source]#
Return the name of the filter rule for the specified group name.
- Usage:
getGroupRuleName([<groupName>, …]) -> { <groupName>:<ruleName>, … }
- or:
getGroupRuleName(<groupName) -> <ruleName>
ucsschool.lib.roles module#
- exception ucsschool.lib.roles.UnknownRole[source]#
Bases:
UcsschoolRoleStringError
- exception ucsschool.lib.roles.UnknownContextType[source]#
Bases:
UcsschoolRoleStringError
- exception ucsschool.lib.roles.InvalidUcsschoolRoleString[source]#
Bases:
UcsschoolRoleStringError
- ucsschool.lib.roles.create_ucsschool_role_string(role: str, context: str, context_type: str | None = 'school', school: str | None = '') str[source]#
This function takes a role, a context_type and a context to create a valid ucsschoolRole string. :param role: The role :param context: The context :param context_type: The context type :param school: Old variable name for context. DEPRECATED! TODO: Should be removed in 4.4v5 :return: The valid ucsschoolRole string
- ucsschool.lib.roles.get_role_info(ucsschool_role_string: str) Tuple[str, str, str][source]#
This function separates the individual elements of an ucsschool role string. Raises InvalidUcsschoolRoleString if the string provided is no valid role string. Raises UnknownRole if the role is unknown. Raises UnknownContextType if the context type is unknown. :param ucsschool_role_string: The role string to separate :return: (role, context_type, context)
ucsschool.lib.school_umc_base module#
- class ucsschool.lib.school_umc_base.SchoolSanitizer(regex_pattern: Pattern[str] | str | None = None, re_flags: int = 0, minimum: int | None = None, maximum: int | None = None, **kwargs: Any)[source]#
Bases:
StringSanitizer
- class ucsschool.lib.school_umc_base.SchoolBaseModule(*args, **kwargs)[source]#
Bases:
BaseThis class serves as base class for UCS@school UMC modules that need LDAP access. It initiates the list of available OUs (self.availableSchools) and initiates the search bases (self.searchBase). set_bind_function() is called automatically to allow LDAP connections. In order to integrate this class into a module, use the following paradigm:
- class Instance(SchoolBaseModule):
- def __init__(self):
# initiate list of internal variables SchoolBaseModule.__init__(self) # … custom code
- def init(self):
SchoolBaseModule.init(self) # … custom code
ucsschool.lib.school_umc_ldap_connection module#
- ucsschool.lib.school_umc_ldap_connection.LDAP_Connection(*connection_types)[source]#
This decorator function provides access to internally cached LDAP connections that can be accessed via adding specific keyword arguments to the function.
The function which uses this decorator may specify the following additional keyword arguments:
- Parameters:
ldap_position (univention.admin.uldap.position) – a valid ldap position.
ldap_user_read – a read only LDAP connection to the local LDAP server authenticated with the currently used user
ldap_user_write – a read/write LDAP connection to the master LDAP server authenticated with the currently used user
ldap_machine_read – a read only LDAP connection to the local LDAP server authenticated with the machine account
ldap_machine_write – a read/write LDAP connection to the master LDAP server authenticated with the machine account
ldap_admin_write – a read/write LDAP connection to the master LDAP server authenticated with cn=admin account
search_base – (deprecated!) a SchoolSearchBase instance which is bound to the school of the user or machine.
This decorator can only be used after
set_bind_function()has been executed.@LDAP_Connection() def do_ldap_stuff(arg1, arg2, ldap_user_write=None, ldap_user_read=None, ldap_position=None): ... ldap_user_read.searchDn(..., position=ldap_position) ...
ucsschool.lib.schoolldap module#
- class ucsschool.lib.schoolldap.SchoolSearchBase(availableSchools: Sequence[str], school: str | None = None, dn: str | None = None, ldapBase: str | None = None)[source]#
Bases:
objectDeprecated: don’t use position to identify user objects
- ucr: ConfigRegistry = <univention.config_registry.backend.ConfigRegistry object>#
- group_prefix_students = 'schueler-'#
- group_prefix_teachers = 'lehrer-'#
- group_prefix_admins = 'admins-'#
- group_prefix_staff = 'mitarbeiter-'#
- classmethod getOU(dn: str) str[source]#
Return the school OU for a given DN.
>>> SchoolSearchBase.getOU('uid=a,fou=bar,Ou=dc1,oU=dc,dc=foo,dc=bar') 'dc1'
- classmethod getOUDN(dn: str) str[source]#
Return the School OU-DN part for a given DN.
>>> SchoolSearchBase.getOUDN('uid=a,fou=bar,Ou=dc1,oU=dc,dc=foo,dc=bar') 'Ou=dc1,oU=dc,dc=foo,dc=bar' >>> SchoolSearchBase.getOUDN('ou=dc1,ou=dc,dc=foo,dc=bar') 'ou=dc1,ou=dc,dc=foo,dc=bar' >>> SchoolSearchBase.getOUDN('dc=foo,dc=bar') 'dc=foo,dc=bar'
ucsschool.lib.schoollessons module#
ucsschool.lib.smbstatus module#
Parser for smbstatus