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

Collapse All | Expand All

(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/password.py (-29 / +12 lines)
 Lines 532-557   def password_sync_ucs_to_s4(s4connector, key, object): Link Here 
532
532
533
	# ud.debug(ud.LDAP, ud.INFO, "password_sync_ucs_to_s4: Password-Hash from UCS: %s" % ucsNThash)
533
	# ud.debug(ud.LDAP, ud.INFO, "password_sync_ucs_to_s4: Password-Hash from UCS: %s" % ucsNThash)
534
534
535
	s4_object_attributes = s4connector.lo_s4.get(compatible_modstring(object['dn']), ['pwdLastSet', 'objectSid'])
535
	s4_object_attributes = s4connector.lo_s4.get(compatible_modstring(object['dn']), ['pwdLastSet', 'unicodePwd', 'userPrincipalName', 'supplementalCredentials', 'msDS-KeyVersionNumber', 'dBCSPwd'])
536
	pwdLastSet = None
536
	pwdLastSet = None
537
	if 'pwdLastSet' in s4_object_attributes:
537
	if 'pwdLastSet' in s4_object_attributes:
538
		pwdLastSet = long(s4_object_attributes['pwdLastSet'][0])
538
		pwdLastSet = long(s4_object_attributes['pwdLastSet'][0])
539
	objectSid = univention.s4connector.s4.decode_sid(s4_object_attributes['objectSid'][0])
539
	objectSid = univention.s4connector.s4.decode_sid(s4_object_attributes['objectSid'][0])
540
	ud.debug(ud.LDAP, ud.INFO, "password_sync_ucs_to_s4: pwdLastSet from S4 : %s" % pwdLastSet)
540
	ud.debug(ud.LDAP, ud.INFO, "password_sync_ucs_to_s4: pwdLastSet from S4 : %s" % pwdLastSet)
541
	# rid = None
542
	# if s4_object_attributes.has_key('objectSid'):
543
	# 	rid = str(univention.s4connector.s4.decode_sid(s4_object_attributes['objectSid'][0]).split('-')[-1])
544
541
545
	pwd_set = False
542
	pwd_set = False
546
	filter_expr = format_escaped('(objectSid={0!e})', objectSid)
543
547
	res = s4connector.lo_s4.search(filter=filter_expr, attr=['unicodePwd', 'userPrincipalName', 'supplementalCredentials', 'msDS-KeyVersionNumber', 'dBCSPwd'])
544
	unicodePwd_attr = s4_object_attributes.get('unicodePwd', [None])[0]
548
	s4_search_attributes = res[0][1]
545
	dBCSPwd_attr = s4_object_attributes.get('dBCSPwd', [None])[0]
549
546
	userPrincipalName_attr = s4_object_attributes.get('userPrincipalName', [None])[0]
550
	unicodePwd_attr = s4_search_attributes.get('unicodePwd', [None])[0]
547
	supplementalCredentials = s4_object_attributes.get('supplementalCredentials', [None])[0]
551
	dBCSPwd_attr = s4_search_attributes.get('dBCSPwd', [None])[0]
548
	msDS_KeyVersionNumber = s4_object_attributes.get('msDS-KeyVersionNumber', [0])[0]
552
	userPrincipalName_attr = s4_search_attributes.get('userPrincipalName', [None])[0]
553
	supplementalCredentials = s4_search_attributes.get('supplementalCredentials', [None])[0]
554
	msDS_KeyVersionNumber = s4_search_attributes.get('msDS-KeyVersionNumber', [0])[0]
555
	# ud.debug(ud.LDAP, ud.INFO, "password_sync_ucs_to_s4: Password-Hash from S4: %s" % unicodePwd_attr)
549
	# ud.debug(ud.LDAP, ud.INFO, "password_sync_ucs_to_s4: Password-Hash from S4: %s" % unicodePwd_attr)
556
550
557
	s4NThash = None
551
	s4NThash = None
 Lines 666-672   def password_sync_s4_to_ucs(s4connector, key, ucs_object, modifyUserPassword=Tru Link Here 
666
			return
660
			return
667
661
668
	object = s4connector._object_mapping(key, ucs_object, 'ucs')
662
	object = s4connector._object_mapping(key, ucs_object, 'ucs')
669
	s4_object_attributes = s4connector.lo_s4.get(compatible_modstring(object['dn']), ['objectSid', 'pwdLastSet'])
663
	s4_object_attributes = s4connector.lo_s4.get(compatible_modstring(object['dn']), ['pwdLastSet', 'unicodePwd', 'supplementalCredentials', 'msDS-KeyVersionNumber', 'dBCSPwd'])
670
664
671
	if s4connector.isInCreationList(object['dn']):
665
	if s4connector.isInCreationList(object['dn']):
672
		s4connector.removeFromCreationList(object['dn'])
666
		s4connector.removeFromCreationList(object['dn'])
 Lines 677-703   def password_sync_s4_to_ucs(s4connector, key, ucs_object, modifyUserPassword=Tru Link Here 
677
	if 'pwdLastSet' in s4_object_attributes:
671
	if 'pwdLastSet' in s4_object_attributes:
678
		pwdLastSet = long(s4_object_attributes['pwdLastSet'][0])
672
		pwdLastSet = long(s4_object_attributes['pwdLastSet'][0])
679
	ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: pwdLastSet from S4: %s (%s)" % (pwdLastSet, s4_object_attributes))
673
	ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: pwdLastSet from S4: %s (%s)" % (pwdLastSet, s4_object_attributes))
680
	objectSid = univention.s4connector.s4.decode_sid(s4_object_attributes['objectSid'][0])
681
682
	# rid = None
683
	# if s4_object_attributes.has_key('objectSid'):
684
	# 	rid = str(univention.s4connector.s4.decode_sid(s4_object_attributes['objectSid'][0]).split('-')[-1])
685
686
	filter_expr = format_escaped('(objectSid={0!e})', objectSid)
687
	res = s4connector.lo_s4.search(filter=filter_expr, attr=['unicodePwd', 'supplementalCredentials', 'msDS-KeyVersionNumber', 'dBCSPwd'])
688
	s4_search_attributes = res[0][1]
689
674
690
	unicodePwd_attr = s4_search_attributes.get('unicodePwd', [None])[0]
675
	unicodePwd_attr = s4_object_attributes.get('unicodePwd', [None])[0]
691
	if unicodePwd_attr:
676
	if unicodePwd_attr:
692
		ntPwd = binascii.b2a_hex(unicodePwd_attr).upper()
677
		ntPwd = binascii.b2a_hex(unicodePwd_attr).upper()
693
678
694
		lmPwd = ''
679
		lmPwd = ''
695
		dBCSPwd = s4_search_attributes.get('dBCSPwd', [None])[0]
680
		dBCSPwd = s4_object_attributes.get('dBCSPwd', [None])[0]
696
		if dBCSPwd:
681
		if dBCSPwd:
697
			lmPwd = binascii.b2a_hex(dBCSPwd).upper()
682
			lmPwd = binascii.b2a_hex(dBCSPwd).upper()
698
683
699
		supplementalCredentials = s4_search_attributes.get('supplementalCredentials', [None])[0]
684
		supplementalCredentials = s4_object_attributes.get('supplementalCredentials', [None])[0]
700
		msDS_KeyVersionNumber = s4_search_attributes.get('msDS-KeyVersionNumber', [0])[0]
685
		msDS_KeyVersionNumber = s4_object_attributes.get('msDS-KeyVersionNumber', [0])[0]
701
686
702
		ntPwd_ucs = ''
687
		ntPwd_ucs = ''
703
		lmPwd_ucs = ''
688
		lmPwd_ucs = ''
704
- 
705
pwdLastSet changed, even if the hashes didn't
689
pwdLastSet changed, even if the hashes didn't
706
--
707
.../modules/univention/s4connector/__init__.py          |  1 +
690
.../modules/univention/s4connector/__init__.py          |  1 +
708
.../modules/univention/s4connector/s4/password.py       | 17 ++++++++++++-----
691
.../modules/univention/s4connector/s4/password.py       | 17 ++++++++++++-----
709
2 files changed, 13 insertions(+), 5 deletions(-)
692
2 files changed, 13 insertions(+), 5 deletions(-)
(-)a/services/univention-s4-connector/modules/univention/s4connector/__init__.py (+1 lines)
 Lines 1554-1559   class ucs: Link Here 
1554
				ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs: old_s4_object: %s" % old_s4_object)
1554
				ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs: old_s4_object: %s" % old_s4_object)
1555
				ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs: new_s4_object: %s" % original_object['attributes'])
1555
				ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs: new_s4_object: %s" % original_object['attributes'])
1556
				if old_s4_object:
1556
				if old_s4_object:
1557
					object['old_s4_object'] = old_s4_object
1557
					for attr in original_object['attributes']:
1558
					for attr in original_object['attributes']:
1558
						if old_s4_object.get(attr) != original_object['attributes'].get(attr):
1559
						if old_s4_object.get(attr) != original_object['attributes'].get(attr):
1559
							object['changed_attributes'].append(attr)
1560
							object['changed_attributes'].append(attr)
(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/password.py (-6 / +12 lines)
 Lines 737-748   def password_sync_s4_to_ucs(s4connector, key, ucs_object, modifyUserPassword=Tru Link Here 
737
			# Append modification as well to modlist, to apply in one transaction
737
			# Append modification as well to modlist, to apply in one transaction
738
			if modifyUserPassword:
738
			if modifyUserPassword:
739
				modlist.append(('userPassword', userPassword_ucs, '{K5KEY}'))
739
				modlist.append(('userPassword', userPassword_ucs, '{K5KEY}'))
740
		else:
741
			ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: No password change to sync to UCS")
742
743
		try:
744
			old_pwdLastSet = object['old_s4_object']['pwdLastSet'][0]
745
		except (KeyError, IndexError):
746
			old_pwdLastSet = None
740
747
748
		if pwdLastSet != old_pwdLastSet:
749
			ud.debug(ud.LDAP, ud.ALL, "password_sync_s4_to_ucs: updating shadowLastChange")
741
			# Update password expiry interval
750
			# Update password expiry interval
742
			#
751
			#
743
			# update shadowLastChange to now
752
			# update shadowLastChange to now
744
			old_shadowLastChange = ucs_object_attributes.get('shadowLastChange', [None])[0]
753
			old_shadowLastChange = ucs_object_attributes.get('shadowLastChange', [None])[0]
745
			new_shadowLastChange = str(long(time.time()) / 3600 / 24)
754
			pwdLastSet_unix = univention.s4connector.s4.s42unix_time(pwdLastSet)
755
			new_shadowLastChange = str(pwdLastSet_unix)
746
			ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: update shadowLastChange to %s for %s" % (new_shadowLastChange, ucs_object['dn']))
756
			ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: update shadowLastChange to %s for %s" % (new_shadowLastChange, ucs_object['dn']))
747
			modlist.append(('shadowLastChange', old_shadowLastChange, new_shadowLastChange))
757
			modlist.append(('shadowLastChange', old_shadowLastChange, new_shadowLastChange))
748
			# shadowMax (set to value of univentionPWExpiryInterval, otherwise delete)
758
			# shadowMax (set to value of univentionPWExpiryInterval, otherwise delete)
 Lines 758-774   def password_sync_s4_to_ucs(s4connector, key, ucs_object, modifyUserPassword=Tru Link Here 
758
				pwexp_value = pwexp.get('value', [None])[0]
768
				pwexp_value = pwexp.get('value', [None])[0]
759
				if pwexp_value:
769
				if pwexp_value:
760
					new_shadowMax = pwexp_value
770
					new_shadowMax = pwexp_value
761
					new_krb5end = time.strftime("%Y%m%d000000Z", time.gmtime((long(time.time()) + (int(pwexp_value) * 3600 * 24))))
771
					new_krb5end = time.strftime("%Y%m%d000000Z", pwdLastSet_unix + (int(pwexp_value) * 3600 * 24))))
762
			if old_shadowMax or new_shadowMax:
772
			if old_shadowMax or new_shadowMax:
763
				ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: update shadowMax to %s for %s" % (new_shadowMax, ucs_object['dn']))
773
				ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: update shadowMax to %s for %s" % (new_shadowMax, ucs_object['dn']))
764
				modlist.append(('shadowMax', old_shadowMax, new_shadowMax))
774
				modlist.append(('shadowMax', old_shadowMax, new_shadowMax))
765
			if old_krb5end or new_krb5end:
775
			if old_krb5end or new_krb5end:
766
				ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: update krb5PasswordEnd to %s for %s" % (new_krb5end, ucs_object['dn']))
776
				ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: update krb5PasswordEnd to %s for %s" % (new_krb5end, ucs_object['dn']))
767
				modlist.append(('krb5PasswordEnd', old_krb5end, new_krb5end))
777
				modlist.append(('krb5PasswordEnd', old_krb5end, new_krb5end))
768
		else:
769
			ud.debug(ud.LDAP, ud.INFO, "password_sync_s4_to_ucs: No password change to sync to UCS")
770
778
771
		if pwd_changed and (pwdLastSet or pwdLastSet == 0):
772
			newSambaPwdMustChange = sambaPwdMustChange
779
			newSambaPwdMustChange = sambaPwdMustChange
773
			if pwdLastSet == 0:  # pwd change on next login
780
			if pwdLastSet == 0:  # pwd change on next login
774
				newSambaPwdMustChange = str(pwdLastSet)
781
				newSambaPwdMustChange = str(pwdLastSet)
775
- 

Return to bug 47391