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

Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/users/user.py (-10 / +12 lines)
 Lines 1094-1101   def posixSecondsToLocaltimeDate(seconds): Link Here 
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 posixDaysToLocalDate(days):
1098
	return time.strftime("%Y-%m-%d", time.gmtime(long(days) * 3600 * 24))
1098
	return time.strftime("%Y-%m-%d", time.localtime(long(days) * 3600 * 24))
1099
1099
1100
1100
1101
def sambaWorkstationsMap(workstations):
1101
def sambaWorkstationsMap(workstations):
 Lines 1267-1288   def unmapShadowExpireToUserexpiry(oldattr): Link Here 
1267
	# shadowExpire contains the absolute date to expire the account.
1267
	# shadowExpire contains the absolute date to expire the account.
1268
1268
1269
	if 'shadowExpire' in oldattr and len(oldattr['shadowExpire']) > 0:
1269
	if 'shadowExpire' in oldattr and len(oldattr['shadowExpire']) > 0:
1270
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'userexpiry: %s' % posixDaysToDate(oldattr['shadowExpire'][0]))
1270
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'userexpiry: %s' % posixDaysToLocalDate(oldattr['shadowExpire'][0]))
1271
		if oldattr['shadowExpire'][0] != '1':
1271
		if oldattr['shadowExpire'][0] != '1':
1272
			return posixDaysToDate(oldattr['shadowExpire'][0])
1272
			return posixDaysToLocalDate(oldattr['shadowExpire'][0])
1273
1273
1274
1274
1275
def unmapKrb5ValidEndToUserexpiry(oldattr):
1275
def unmapKrb5ValidEndToUserexpiry(oldattr):
1276
	if 'krb5ValidEnd' in oldattr:
1276
	if 'krb5ValidEnd' in oldattr:
1277
		krb5validend = oldattr['krb5ValidEnd'][0]
1277
		krb5validend = oldattr['krb5ValidEnd'][0]
1278
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'krb5validend is: %s' % krb5validend)
1278
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'krb5validend is: %s' % krb5validend)
1279
		return "%s-%s-%s" % (krb5validend[0:4], krb5validend[4:6], krb5validend[6:8])
1279
		userexpiry_epoch = calendar.timegm(time.strptime(krb5validend, '%Y%m%d%H%M%SZ'))
1280
		return time.strftime("%Y-%m-%d", time.localtime(userexpiry_epoch))
1280
1281
1281
1282
1282
def unmapSambaKickoffTimeToUserexpiry(oldattr):
1283
def unmapSambaKickoffTimeToUserexpiry(oldattr):
1283
	if 'sambaKickoffTime' in oldattr:
1284
	if 'sambaKickoffTime' in oldattr:
1284
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'sambaKickoffTime is: %s' % oldattr['sambaKickoffTime'][0])
1285
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'sambaKickoffTime is: %s' % oldattr['sambaKickoffTime'][0])
1285
		return time.strftime("%Y-%m-%d", time.gmtime(long(oldattr['sambaKickoffTime'][0]) + (3600 * 24)))
1286
		return time.strftime("%Y-%m-%d", time.localtime(long(oldattr['sambaKickoffTime'][0]) + (3600 * 24)))
1286
1287
1287
1288
1288
def unmapPasswordExpiry(oldattr):
1289
def unmapPasswordExpiry(oldattr):
 Lines 1293-1299   def unmapPasswordExpiry(oldattr): Link Here 
1293
			shadow_last_change = int(oldattr['shadowLastChange'][0])
1294
			shadow_last_change = int(oldattr['shadowLastChange'][0])
1294
		except ValueError:
1295
		except ValueError:
1295
			univention.debug.debug(univention.debug.ADMIN, univention.debug.WARN, 'users/user: failed to calculate password expiration correctly, use only shadowMax instead')
1296
			univention.debug.debug(univention.debug.ADMIN, univention.debug.WARN, 'users/user: failed to calculate password expiration correctly, use only shadowMax instead')
1296
		return posixDaysToDate(shadow_last_change + shadow_max)
1297
		return posixDaysToLocalDate(shadow_last_change + shadow_max)
1297
1298
1298
1299
1299
def unmapDisabled(oldattr):
1300
def unmapDisabled(oldattr):
 Lines 2048-2054   class object(univention.admin.handlers.simpleLdap): Link Here 
2048
			return ml
2049
			return ml
2049
2050
2050
		krb_keys = univention.admin.password.krb5_asn1(self.krb5_principal(), self['password'])
2051
		krb_keys = univention.admin.password.krb5_asn1(self.krb5_principal(), self['password'])
2051
		krb_key_version = str(int(self.oldattr.get('krb5KeyVersionNumber', ['0'])[0]) + 1)
2052
		krb_key_version = str(int(self.oldattr.get('krb5KeyVersionNumber', ['0'])[0]))
2052
		ml.append(('krb5Key', self.oldattr.get('krb5Key', []), krb_keys))
2053
		ml.append(('krb5Key', self.oldattr.get('krb5Key', []), krb_keys))
2053
		ml.append(('krb5KeyVersionNumber', self.oldattr.get('krb5KeyVersionNumber', []), krb_key_version))
2054
		ml.append(('krb5KeyVersionNumber', self.oldattr.get('krb5KeyVersionNumber', []), krb_key_version))
2054
		return ml
2055
		return ml
 Lines 2193-2199   class object(univention.admin.handlers.simpleLdap): Link Here 
2193
		if self.hasChanged('userexpiry'):
2194
		if self.hasChanged('userexpiry'):
2194
			krb5ValidEnd = ''
2195
			krb5ValidEnd = ''
2195
			if self['userexpiry']:
2196
			if self['userexpiry']:
2196
				krb5ValidEnd = "%s%s%s000000Z" % (self['userexpiry'][0:4], self['userexpiry'][5:7], self['userexpiry'][8:10])
2197
				userexpiry_epoch = time.mktime(time.strptime(self['userexpiry'], "%Y-%m-%d"))
2198
				krb5ValidEnd = time.strftime("%Y%m%d000000Z", time.gmtime(userexpiry_epoch))
2197
				univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'krb5ValidEnd: %s' % krb5ValidEnd)
2199
				univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'krb5ValidEnd: %s' % krb5ValidEnd)
2198
			old_krb5ValidEnd = self.oldattr.get('krb5ValidEnd', '')
2200
			old_krb5ValidEnd = self.oldattr.get('krb5ValidEnd', '')
2199
			if old_krb5ValidEnd != krb5ValidEnd:
2201
			if old_krb5ValidEnd != krb5ValidEnd:
 Lines 2208-2214   class object(univention.admin.handlers.simpleLdap): Link Here 
2208
			if self['disabled'] == '1' and self.hasChanged('disabled') and not self.hasChanged('userexpiry'):
2210
			if self['disabled'] == '1' and self.hasChanged('disabled') and not self.hasChanged('userexpiry'):
2209
				shadowExpire = '1'
2211
				shadowExpire = '1'
2210
			elif self['userexpiry']:
2212
			elif self['userexpiry']:
2211
				shadowExpire = "%d" % long(time.mktime(time.strptime(self['userexpiry'], "%Y-%m-%d")) / 3600 / 24 + 1)
2213
				shadowExpire = "%d" % long(time.mktime(time.strptime(self['userexpiry'], "%Y-%m-%d")) / 3600 / 24)
2212
			elif self['disabled'] == '1':
2214
			elif self['disabled'] == '1':
2213
				shadowExpire = '1'
2215
				shadowExpire = '1'
2214
			else:
2216
			else:
(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py (-9 / +11 lines)
 Lines 215-233   def encode_s4_resultlist(s4_resultlist): Link Here 
215
	return s4_resultlist
215
	return s4_resultlist
216
216
217
217
218
def unix2s4_time(l):
218
def userexpiry2accountExpires(l):
219
	d = 116444736000000000L  # difference between 1601 and 1970
219
	d = 116444736000000000L  # difference between 1601 and 1970
220
	return long(time.mktime(time.gmtime(time.mktime(time.strptime(l, "%Y-%m-%d")) + 90000))) * 10000000 + d  # 90000s are one day and one hour
220
	return long(time.mktime(time.strptime(l, "%Y-%m-%d")) - 86400) * 10000000 + d  # 86400s is one day
221
221
222
222
223
def s42unix_time(l):
223
def accountExpires2userexpiry(l):
224
	d = 116444736000000000L  # difference between 1601 and 1970
224
	d = 116444736000000000L  # difference between 1601 and 1970
225
	return time.strftime("%d.%m.%y", time.gmtime((l - d) / 10000000))
225
	return time.strftime("%Y-%m-%d", time.localtime((l - d) / 10000000) + 86400)
226
226
227
227
228
def samba2s4_time(l):
228
def samba2s4_time(l):
229
	d = 116444736000000000L  # difference between 1601 and 1970
229
	d = 116444736000000000L  # difference between 1601 and 1970
230
	return long(time.mktime(time.localtime(l))) * 10000000 + d
230
	return long(l) * 10000000 + d
231
231
232
232
233
def s42samba_time(l):
233
def s42samba_time(l):
 Lines 2129-2137   class s4(univention.s4connector.ucs): Link Here 
2129
				modlist.append((ldap.MOD_REPLACE, 'accountExpires', ['9223372036854775807']))
2129
				modlist.append((ldap.MOD_REPLACE, 'accountExpires', ['9223372036854775807']))
2130
		else:
2130
		else:
2131
			# ucs account expired
2131
			# ucs account expired
2132
			if 'accountExpires' in ldap_object_s4 and ldap_object_s4['accountExpires'][0] != unix2s4_time(ucs_admin_object['userexpiry']):
2132
			accountExpires_ucs = userexpiry2accountExpires(ucs_admin_object['userexpiry'])
2133
			if 'accountExpires' in ldap_object_s4 and ldap_object_s4['accountExpires'][0] != accountExpires_ucs:
2133
				# s4 account not expired -> change
2134
				# s4 account not expired -> change
2134
				modlist.append((ldap.MOD_REPLACE, 'accountExpires', [str(unix2s4_time(ucs_admin_object['userexpiry']))]))
2135
				modlist.append((ldap.MOD_REPLACE, 'accountExpires', [str(accountExpires_ucs)]))
2135
2136
2136
		if modlist:
2137
		if modlist:
2137
			ud.debug(ud.LDAP, ud.ALL, "disable_user_from_ucs: modlist: %s" % modlist)
2138
			ud.debug(ud.LDAP, ud.ALL, "disable_user_from_ucs: modlist: %s" % modlist)
 Lines 2171-2179   class s4(univention.s4connector.ucs): Link Here 
2171
			# s4 account expired
2172
			# s4 account expired
2172
			ud.debug(ud.LDAP, ud.INFO, "sync account_expire:      s4time: %s    unixtime: %s" % (long(ldap_object_s4['accountExpires'][0]), ucs_admin_object['userexpiry']))
2173
			ud.debug(ud.LDAP, ud.INFO, "sync account_expire:      s4time: %s    unixtime: %s" % (long(ldap_object_s4['accountExpires'][0]), ucs_admin_object['userexpiry']))
2173
2174
2174
			if s42unix_time(long(ldap_object_s4['accountExpires'][0])) != ucs_admin_object['userexpiry']:
2175
			userexpiry_s4 = accountExpires2userexpiry(long(ldap_object_s4['accountExpires'][0]))
2176
			if userexpiry_s4 != ucs_admin_object['userexpiry']:
2175
				# ucs account not expired -> change
2177
				# ucs account not expired -> change
2176
				ucs_admin_object['userexpiry'] = s42unix_time(long(ldap_object_s4['accountExpires'][0]))
2178
				ucs_admin_object['userexpiry'] = userexpiry_s4
2177
				modified = 1
2179
				modified = 1
2178
2180
2179
		if modified:
2181
		if modified:

Return to bug 41574