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

Collapse All | Expand All

(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py (-16 / +17 lines)
 Lines 39-44   import string Link Here 
39
import re
39
import re
40
import sys
40
import sys
41
import time
41
import time
42
import calendar
42
import types
43
import types
43
import array
44
import array
44
import univention.uldap
45
import univention.uldap
 Lines 215-240   def encode_s4_resultlist(s4_resultlist): Link Here 
215
	return s4_resultlist
216
	return s4_resultlist
216
217
217
218
218
def unix2s4_time(l):
219
def samba2s4_time(unix_ts):
219
	d = 116444736000000000L  # difference between 1601 and 1970
220
	delta = 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
221
	as_nanoseconds = unix_ts * 10000000
222
	return as_nanoseconds + delta
221
223
222
224
223
def s42unix_time(l):
225
def s42samba_time(s4_ts):
224
	d = 116444736000000000L  # difference between 1601 and 1970
226
	delta = 116444736000000000L  # difference between 1601 and 1970
225
	return time.strftime("%d.%m.%y", time.gmtime((l - d) / 10000000))
227
	if s4_ts == 0:
228
		return 0
229
	nanoseconds_since_epoch = s4_ts - delta
230
	return nanoseconds_since_epoch / 10000000
226
231
227
232
228
def samba2s4_time(l):
233
def unix2s4_time(iso_date):
229
	d = 116444736000000000L  # difference between 1601 and 1970
234
	since_epoch = calendar.timegm(time.strptime(iso_date, '%Y-%m-%d'))
230
	return long(time.mktime(time.localtime(l))) * 10000000 + d
235
	return samba2s4_time(since_epoch)
231
236
232
237
233
def s42samba_time(l):
238
def s42unix_time(s4_ts):
234
	if l == 0:
239
	since_epoch = s42samba_time(s4_ts)
235
		return l
240
	return time.strftime('%Y-%m-%d', time.gmtime(since_epoch))
236
	d = 116444736000000000L  # difference between 1601 and 1970
237
	return long(((l - d)) / 10000000)
238
241
239
# mapping funtions
242
# mapping funtions
240
243
241
- 
242
--
243
.../modules/univention/s4connector/s4/__init__.py                | 9 +++++----
244
.../modules/univention/s4connector/s4/__init__.py                | 9 +++++----
244
1 file changed, 5 insertions(+), 4 deletions(-)
245
1 file changed, 5 insertions(+), 4 deletions(-)
(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py (-5 / +5 lines)
 Lines 2164-2170   class s4(univention.s4connector.ucs): Link Here 
2164
				# user enabled in UCS -> change
2164
				# user enabled in UCS -> change
2165
				ucs_admin_object['disabled'] = 'all'
2165
				ucs_admin_object['disabled'] = 'all'
2166
				modified = 1
2166
				modified = 1
2167
		if 'accountExpires' in ldap_object_s4 and (long(ldap_object_s4['accountExpires'][0]) == long(9223372036854775807) or ldap_object_s4['accountExpires'][0] == '0'):
2167
		account_expires = long(ldap_object_s4['accountExpires'][0])
2168
		if 'accountExpires' in ldap_object_s4 and account_expires in (9223372036854775807, 0):
2168
			# s4 account not expired
2169
			# s4 account not expired
2169
			if ucs_admin_object['userexpiry']:
2170
			if ucs_admin_object['userexpiry']:
2170
				# ucs account expired -> change
2171
				# ucs account expired -> change
 Lines 2172-2182   class s4(univention.s4connector.ucs): Link Here 
2172
				modified = 1
2173
				modified = 1
2173
		else:
2174
		else:
2174
			# s4 account expired
2175
			# s4 account expired
2175
			ud.debug(ud.LDAP, ud.INFO, "sync account_expire:      s4time: %s    unixtime: %s" % (long(ldap_object_s4['accountExpires'][0]), ucs_admin_object['userexpiry']))
2176
			ud.debug(ud.LDAP, ud.INFO, "sync account_expire:      s4time: %s    unixtime: %s" % (account_expires, ucs_admin_object['userexpiry']))
2176
2177
2177
			if s42unix_time(long(ldap_object_s4['accountExpires'][0])) != ucs_admin_object['userexpiry']:
2178
			if s42unix_time(account_expires) != ucs_admin_object['userexpiry']:
2178
				# ucs account not expired -> change
2179
				# ucs account not expired -> change
2179
				ucs_admin_object['userexpiry'] = s42unix_time(long(ldap_object_s4['accountExpires'][0]))
2180
				ucs_admin_object['userexpiry'] = s42unix_time(account_expires)
2180
				modified = 1
2181
				modified = 1
2181
2182
2182
		if modified:
2183
		if modified:
2183
- 

Return to bug 41574