-
Notifications
You must be signed in to change notification settings - Fork 367
Description
TL;DR
How do I update PASSWD_CANT_CHANGE
in the security descriptor discretionary access control list to set the ADS_ACETYPE_ACCESS_DENIED_OBJECT
ace type in the IADsAccessControlEntry
?
Note: VB.net example found at the bottom
My Best Guess
My best guess is that I can use the ldap control to do something, but I cannot find any reference for it.
controls := []ldap.Control{}
Details
When activating an account, the following will activate with DONT_EXPIRE_PASSWORD
and NORMAL_ACCOUNT
. However, attempting to use 0x0040
for PASSWD_CANT_CHANGE
has no effect.
controls := []ldap.Control{}
enableReq := ldap.NewModifyRequest(userDN, controls)
enableReq.Replace("userAccountControl", []string{fmt.Sprintf("%d", 0x10200)})
According to this page reference:
Note You cannot assign this permission by directly modifying the UserAccountControl attribute. For information about how to set the permission programmatically, see the "Property flag descriptions" section.
The above redirection leads to this page, where it lists the following steps to update this option.
- Bind to the user object.
- Obtain the
IADsSecurityDescriptor
object from thentSecurityDescriptor
property of the user object. - Obtain an
IADsAccessControlList
interface for the security descriptor from theIADsSecurityDescriptor.DiscretionaryAcl
property. - Enumerate the ACEs for the object and search for the ACEs that have the change password GUID ({AB721A53-1E2F-11D0-9819-00AA0040529B}) for the IADsAccessControlEntry.ObjectType property and "Everyone" or "NT AUTHORITY\SELF" for the
IADsAccessControlEntry
.Trustee property.
5.Modify theIADsAccessControlEntry.AceType
property of the ACEs that were found toADS_ACETYPE_ACCESS_DENIED_OBJECT
if the user cannot change their password orADS_ACETYPE_ACCESS_ALLOWED_OBJECT
if the user can change their password. - If the "Everyone" ACE is not found, create a new
IADsAccessControlEntry
object that contains the property values shown in the table below and add the new entry to the ACL with theIADsAccessControlList.AddAce
method. - If the "NT AUTHORITY\SELF" ACE is not found, create a new
IADsAccessControlEntry
object with the same property values shown in the table below except the Trustee property contains the account name for SID "S-1-5-10" ("NT AUTHORITY\SELF"). Add the entry to the ACL with theIADsAccessControlList.AddAce
method. - To update the
ntSecurityDescriptor
property of the object, call the IADs.Put method with the sameIADsSecurityDescriptor
obtained in Step 2. - Commit the local changes to the server with the IADs.SetInfo method.
- If either of the ACEs were created, you must reorder the ACL so that the ACEs are in the correct order. To do this, call the
GetNamedSecurityInfo
function with the LDAP ADsPath of the object and then theSetNamedSecurityInfo
function with the same DACL. This reordering will occur automatically when the ACEs are added.
More information here with examples on this setting for ADS_ACETYPE_ACCESS_DENIED_OBJECT
Set x = GetObject("LDAP://OU=Sales, DC=Fabrikam,DC=com")
Dim sd As IADsSecurityDescriptor
Set sd = x.Get("ntSecurityDescriptor")
Dim Ace2 As New AccessControlEntry
Dim Dacl As IADsAccessControlList
Set Dacl = sd.DiscretionaryAcl
Ace2.AccessMask = -1 'Full Permission (Denied)
Ace2.AceType = ADS_ACETYPE_ACCESS_DENIED
Ace2.AceFlags = ADS_ACEFLAG_INHERIT_ACE
Ace2.Trustee = "ACTIVED\Andyhar"
Dacl.AddAce Ace2
sd.DiscretionaryAcl = Dacl
x.Put "ntSecurityDescriptor", Array(sd)
x.SetInfo