Source code for univention.admin.uexceptions
# SPDX-FileCopyrightText: 2004-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only
"""|UDM| exceptions."""
from univention.admin import localization
from univention.admin._ucr import configRegistry
translation = localization.translation('univention/admin')
_ = translation.translate
def _strip(string):
return string.strip().strip('.:').strip()
def _strip_and_append(string, char='.'):
string = _strip(string)
return '%s%s' % (string, char) if not string.endswith('!') else string
[docs]
class base(Exception):
message = ''
def __str__(self):
args = []
if self.message:
args = [_(self.message)] # re-translate because it was done on import-time where the locale is not necessarily set
for msg in self.args:
if msg is None:
continue
msg = str(msg)
# avoid duplicate messages
if all(_strip(msg) not in arg for arg in [*args, self.message]):
args.append(msg)
# make sure that a ':' is printed if further information follows
if len(args) == 1:
args[0] = _strip_and_append(args[0])
elif len(args) > 1:
args[0] = _strip_and_append(args[0], ':')
args[1:] = [_strip_and_append(a) for a in args[1:]]
return ' '.join(args)
[docs]
class objectExists(base):
message = _('Object exists.')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.dn = self.args[0] if self.args else None
[docs]
class noObject(base):
message = _('No such object.')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.dn = self.args[0] if self.args else None
[docs]
class permissionDenied(base):
message = _('Permission denied.')
[docs]
class ldapError(base):
message = _('LDAP Error')
def __init__(self, *args, **kwargs):
self.original_exception = kwargs.pop('original_exception', None)
super().__init__(*args, **kwargs)
[docs]
class ldapTimeout(base):
message = _('The specified timeout for the LDAP search has been exceeded.')
[docs]
class ldapSizelimitExceeded(base):
message = _('The specified size limit for the LDAP search has been exceeded.')
[docs]
class noSuperordinate(insufficientInformation):
pass
[docs]
class noProperty(base):
message = _('No such property.')
[docs]
class valueError(base):
"""Value error base class"""
def __init__(self, *args, **kwargs):
self.property = kwargs.pop('property', None)
super().__init__(*args, **kwargs)
[docs]
class valueMayNotChange(valueError):
message = _('Value may not change.')
[docs]
class valueInvalidSyntax(valueError):
message = _('Invalid syntax.')
[docs]
class valueRequired(valueError):
message = _('Value is required.')
[docs]
class valueMismatch(valueError):
message = _('Values do not match.')
[docs]
class noLock(base):
message = _('Could not acquire lock.')
[docs]
class authFail(base):
message = _('Authentication Failed.')
[docs]
class uidAlreadyUsed(base):
if configRegistry.is_true('directory/manager/user_group/uniqueness', True):
message = _('The username is already in use as username or as groupname')
else:
message = _('The username is already in use')
[docs]
class sidAlreadyUsed(base):
message = _('The relative ID (SAMBA) is already in use.')
[docs]
class groupNameAlreadyUsed(base):
if configRegistry.is_true('directory/manager/user_group/uniqueness', True):
message = _('The groupname is already in use as groupname or as username')
else:
message = _('The groupname is already in use')
[docs]
class uidNumberAlreadyUsedAsGidNumber(base):
message = _('The uidNumber is already in use as a gidNumber')
[docs]
class gidNumberAlreadyUsedAsUidNumber(base):
message = _('The gidNumber is already in use as a uidNumber')
[docs]
class adGroupTypeChangeLocalToAny(base):
message = _('The AD group type can not be changed from type local to any other type.')
[docs]
class adGroupTypeChangeToLocal(base):
message = _('The AD group type can not be changed to type local.')
[docs]
class adGroupTypeChangeGlobalToUniversal(base):
message = _('The AD group type can not be changed from global to universal, because the group is member of another global group.')
[docs]
class adGroupTypeChangeDomainLocalToUniversal(base):
message = _('The AD group type can not be changed from domain local to universal, because the group has another domain local group as member.')
[docs]
class adGroupTypeChangeUniversalToGlobal(base):
message = _('The AD group type can not be changed from universal to global, because the group has another universal group as member.')
[docs]
class adGroupTypeChangeGlobalToDomainLocal(base):
message = _('The AD group type can not be changed from global to domain local.')
[docs]
class adGroupTypeChangeDomainLocalToGlobal(base):
message = _('The AD group type can not be changed from domain local to global.')
[docs]
class prohibitedUsername(base):
message = _('Prohibited username.')
[docs]
class ipAlreadyUsed(base):
message = _('IP address is already in use.')
[docs]
class dnsAliasAlreadyUsed(base):
message = _('DNS alias is already in use.')
[docs]
class invalidDhcpEntry(base):
message = _('The DHCP entry for this host should contain the zone DN, the IP address and the MAC address.')
[docs]
class invalidDNSAliasEntry(base):
message = _('The DNS alias entry for this host should contain the zone name, the alias zone container DN and the alias.')
[docs]
class nextFreeIp(base):
message = _('Next IP address not found.')
[docs]
class ipOverridesNetwork(base):
message = _('The given IP address is not within the range of the selected network')
[docs]
class macAlreadyUsed(base):
message = _('The MAC address is already in use.')
[docs]
class mailAddressUsed(base):
message = _('The mail address is already in use.')
[docs]
class dhcpServerAlreadyUsed(base):
message = _('DHCP server name already used: ')
[docs]
class kolabHomeServer(base):
message = _('Default Kolab home server does not exist')
[docs]
class primaryGroup(base):
message = _('Default primary group does not exist')
[docs]
class primaryGroupUsed(base):
message = _('This is a primary group.')
[docs]
class homeShareUsed(base):
message = ''
[docs]
class groupNotFound(base):
message = _('The requested group not be found.')
[docs]
class dhcpNotFound(base):
message = _('The DHCP entry was not found.')
[docs]
class dnsNotFound(base):
message = _('The DNS entry was not found')
[docs]
class policyFixedAttribute(base):
message = _('Cannot overwrite a fixed attribute.')
[docs]
class bootpXORFailover(base):
message = _('Dynamic BOOTP leases are not compatible with failover.')
[docs]
class licenseNotFound(base):
message = _('No license found.')
[docs]
class licenseInvalid(base):
message = _('The license is invalid.')
[docs]
class licenseExpired(base):
message = _('The license is expired.')
[docs]
class licenseWrongBaseDn(base):
message = _('The license is invalid for the current base DN.')
[docs]
class licenseCoreEdition(base):
message = 'UCS Core Edition.'
[docs]
class freeForPersonalUse(base):
message = 'Free for personal use edition.'
[docs]
class licenseAccounts(base):
message = _('Too many user accounts')
[docs]
class licenseClients(base):
message = _('Too many client accounts')
[docs]
class licenseDesktops(base):
message = _('Too many desktop accounts')
[docs]
class licenseGroupware(base):
message = _('Too many groupware accounts')
[docs]
class licenseUsers(base):
message = _('Too many users')
[docs]
class licenseServers(base):
message = _('Too many servers')
[docs]
class licenseManagedClients(base):
message = _('Too many managed clients')
[docs]
class licenseCorporateClients(base):
message = _('Too many corporate clients')
[docs]
class licenseDVSUsers(base):
message = _('Too many DVS users')
[docs]
class licenseDVSClients(base):
message = _('Too many DVS clients')
[docs]
class licenseDisableModify(base):
message = _('During this session add and modify are disabled')
[docs]
class pwalreadyused(base):
message = _('Password has been used before. Please choose a different one.')
[docs]
class passwordLength(base):
message = _('The password is too short, at least 8 character!')
[docs]
class rangeNotInNetwork(base):
message = _('Network and IP range are incompatible.')
[docs]
class rangeInNetworkAddress(base):
message = _('The IP range contains its network address. That is not permitted!')
[docs]
class rangeInBroadcastAddress(base):
message = _('The IP range contains its broadcast address. That is not permitted!')
[docs]
class rangesOverlapping(base):
message = _('Overlapping IP ranges')
[docs]
class invalidOptions(base):
message = _('Invalid combination of options.')
[docs]
class pwToShort(base):
message = _('Password policy error: ')
[docs]
class pwQuality(base):
message = _('Password policy error: ')
[docs]
class invalidOperation(base):
message = _('This operation is not allowed on this object.')
[docs]
class restoreFailed(base):
message = _('Restore operation failed.')
[docs]
class emptyPrinterGroup(base):
message = _('Empty printer groups are not possible.')
[docs]
class leavePrinterGroup(base):
message = _('Printer groups with quota support can only have members with quota support.')
[docs]
class notValidPrinter(base):
message = _('Only printer objects can be members of a printer group.')
[docs]
class notValidGroup(base):
message = _('Only existing groups are allowed.')
[docs]
class notValidUser(base):
message = _('Only existing users are allowed.')
[docs]
class templateSyntaxError(base):
message = _('Invalid syntax in default value. Check these templates: %s.')
def __init__(self, templates):
self.templates = templates
[docs]
class nagiosARecordRequired(base):
message = _('IP address entry required to assign Nagios services!')
[docs]
class nagiosDNSForwardZoneEntryRequired(base):
message = _('DNS Forward Zone entry required to assign Nagios services!')
[docs]
class dnsAliasRecordExists(base):
message = _('The DNS forward entry could not be created. Please remove existing alias records or comparable DNS objects with the same name as this host from the forward zone.')
[docs]
class circularGroupDependency(base):
message = _('Circular group dependency detected: ')
[docs]
class invalidChild(base):
pass
[docs]
class primaryGroupWithoutSamba(base):
message = _('Need a primary group with samba option to create a user with samba option')
[docs]
class wrongObjectType(base):
message = _('The object type of this object differs from the specified object type.')
[docs]
class noKerberosRealm(base):
message = _('There was no valid kerberos realm found.')
[docs]
class alreadyUsedInSubtree(base):
message = _('An object with the name already exists in the subtree position')