Hello Remco,
To set the Password never expires option for a user, you need to set the ADS_UF_DONT_EXPIRE_PASSWD flag in Account Options. Also, you need to disable the User must change password at next logon option (if it is set), which is the same as assigning the value of -1 to the Password Last Set property.
Here's an example on how to do this with the help of a script:
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)
[int]$passwordNeverExpires = [Softerra.Adaxes.Interop.Adsi.PersistentObjects.ADS_USER_FLAG_ENUM]::ADS_UF_DONT_EXPIRE_PASSWD
# Set the 'Password never expires' flag for the user
$user.Put("userAccountControl", $passwordNeverExpires)
# Set a bitmask for the Account Options property so that
# only the 'Password never expires' flag gets updated
$user.PutPropertyItemMask("userAccountControl", $passwordNeverExpires)
# Remove the 'User must change password at next logon' flag if it is set
$passwordLastSet = $user.Get("pwdLastSet")
if ($passwordLastSet -eq 0)
{
$user.Put("pwdLastSet", -1)
}
# Save changes
$user.SetInfo()