Hi
I am working on a script to replicate account settings between two AD domains. One topic is the parameter "user cannot change password". The "problem" with enabling this setting is that I have two pieces of code that seem to do it:
or:
Since there is so much difference between those 2 code samples I was wondering if I can just pick either one to do what I need or if I should pay attention to some conditions? Can anyone help me out with this?
Thanks!
I am working on a script to replicate account settings between two AD domains. One topic is the parameter "user cannot change password". The "problem" with enabling this setting is that I have two pieces of code that seem to do it:
Code:
Const ADS_UF_PASSWD_CANT_CHANGE = &H0040
Set objUser = GetObject("WinNT://mydomain.com/UserID")
objPasswordNoChangeFlag = objUser.UserFlags OR ADS_UF_PASSWD_CANT_CHANGE
objUser.Put "userFlags", objPasswordNoChangeFlag
objUser.SetInfo
or:
Code:
Set objUser = GetObject("WinNT://mydomain.com/UserID")
Set objSD = objUser.Get("ntSecurityDescriptor")
Set objDACL = objSD.DiscretionaryAcl
arrTrustees = array("nt authority\self", "EVERYONE")
For Each strTrustee in arrTrustees
Set objACE = CreateObject("AccessControlEntry")
objACE.Trustee = strTrustee
objACE.AceFlags = 0
objACE.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT
objACE.Flags = ADS_ACEFLAG_OBJECT_TYPE_PRESENT
objACE.ObjectType = CHANGE_PASSWORD_GUID
objACE.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
objDACL.AddAce objACE
Next
objSD.DiscretionaryAcl = objDACL
objUser.Put "nTSecurityDescriptor", objSD
objUser.SetInfo
Since there is so much difference between those 2 code samples I was wondering if I can just pick either one to do what I need or if I should pay attention to some conditions? Can anyone help me out with this?
Thanks!