View | Details | Raw Unified | Return to bug 45842 | Differences between
and this patch

Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/users/user.py (-26 / +22 lines)
 Lines 292-298    Link Here 
292
	'unlockTime': univention.admin.property(
292
	'unlockTime': univention.admin.property(
293
		short_description=_('Lockout till'),
293
		short_description=_('Lockout till'),
294
		long_description=_('Shows the time when the account gets unlocked again according to policy.'),
294
		long_description=_('Shows the time when the account gets unlocked again according to policy.'),
295
		syntax=univention.admin.syntax.string, # see posixSecondsToLocaltimeDate
295
		syntax=univention.admin.syntax.string,  # see posixSecondsToLocaltimeDate
296
		default=None,
296
		default=None,
297
		multivalue=False,
297
		multivalue=False,
298
		required=False,
298
		required=False,
 Lines 1091-1097   def case_insensitive_in_list(dn, list): Link Here 
1091
1091
1092
1092
1093
def posixSecondsToLocaltimeDate(seconds):
1093
def posixSecondsToLocaltimeDate(seconds):
1094
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds))
1094
	return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds))
1095
1095
1096
1096
1097
def posixDaysToDate(days):
1097
def posixDaysToDate(days):
 Lines 1519-1533   def open(self, loadGroups=True): Link Here 
1519
			self._unmap_automount_information()
1519
			self._unmap_automount_information()
1520
			self._unmapUnlockTime()
1520
			self._unmapUnlockTime()
1521
			self.reload_certificate()
1521
			self.reload_certificate()
1522
			self._load_groups(loadGroups)
1522
1523
1523
		self._load_groups(loadGroups)
1524
		self.save()
1524
		if self.exists():
1525
		if not self.exists():  # TODO: move this block into _ldap_pre_create!
1525
			self.save()
1526
			self._set_default_group()
1526
		else:
1527
			pass
1528
			# In this case self.save() must not be called at the end of self.open()
1529
			# otherwise self.__primary_group doesn't add a new user to the
1530
			# univentionDefaultGroup because "not self.hasChanged('primaryGroup')"
1531
1527
1532
	def _load_groups(self, loadGroups):
1528
	def _load_groups(self, loadGroups):
1533
		if self.exists():
1529
		if self.exists():
 Lines 1561-1583   def _load_groups(self, loadGroups): Link Here 
1561
				self.info['primaryGroup'] = None
1557
				self.info['primaryGroup'] = None
1562
				self.save()
1558
				self.save()
1563
				raise univention.admin.uexceptions.primaryGroup(self.dn)
1559
				raise univention.admin.uexceptions.primaryGroup(self.dn)
1564
		else:
1565
			primary_group_from_template = self['primaryGroup']
1566
			if not primary_group_from_template:
1567
				searchResult = self.lo.search(filter='(objectClass=univentionDefault)', base='cn=univention,' + self.position.getDomain(), attr=['univentionDefaultGroup'])
1568
				if not searchResult or not searchResult[0][1]:
1569
					self.info['primaryGroup'] = None
1570
					self.save()
1571
					raise univention.admin.uexceptions.primaryGroup(self.dn)
1572
1573
				for tmp, number in searchResult:
1574
					primaryGroupResult = self.lo.searchDn(filter=filter_format('(&(objectClass=posixGroup)(cn=%s))', (univention.admin.uldap.explodeDn(number['univentionDefaultGroup'][0], 1)[0],)), base=self.position.getDomain(), scope='domain')
1575
					if primaryGroupResult:
1576
						self['primaryGroup'] = primaryGroupResult[0]
1577
						# self.save() must not be called after this point in self.open()
1578
						# otherwise self.__primary_group doesn't add a new user to the
1579
						# univentionDefaultGroup because "not self.hasChanged('primaryGroup')"
1580
1560
1561
	def _set_default_group(self):
1562
		primary_group_from_template = self['primaryGroup']
1563
		if not primary_group_from_template:
1564
			searchResult = self.lo.search(filter='(objectClass=univentionDefault)', base='cn=univention,' + self.position.getDomain(), attr=['univentionDefaultGroup'])
1565
			if not searchResult or not searchResult[0][1]:
1566
				self.info['primaryGroup'] = None
1567
				self.save()
1568
				raise univention.admin.uexceptions.primaryGroup(self.dn)
1569
1570
			for tmp, number in searchResult:
1571
				primaryGroupResult = self.lo.searchDn(filter=filter_format('(&(objectClass=posixGroup)(cn=%s))', (univention.admin.uldap.explodeDn(number['univentionDefaultGroup'][0], 1)[0],)), base=self.position.getDomain(), scope='domain')
1572
				if primaryGroupResult:
1573
					self['primaryGroup'] = primaryGroupResult[0]
1574
					# self.save() must not be called after this point in self.open()
1575
					# otherwise self.__primary_group doesn't add a new user to the
1576
					# univentionDefaultGroup because "not self.hasChanged('primaryGroup')"
1581
1577
1582
	def _unmap_pwd_change_next_login(self):
1578
	def _unmap_pwd_change_next_login(self):
1583
		if self.oldattr.get('shadowLastChange', [''])[0] == '0':
1579
		if self.oldattr.get('shadowLastChange', [''])[0] == '0':

Return to bug 45842