How to force a password change programmatically in Active Dictionary Options

codeling Posts: 1109 Points: 4668
Posted: Tuesday, September 17, 2019 4:20:31 PM

To force a user to change their password at next logon, set the pwdLastSet attribute to zero (0). To remove this requirement, set the pwdLastSet attribute to -1. The pwdLastSet attribute cannot be set to any other value except by the system.

The following C# code example shows how to set the "User must change password at next logon" option.

  var directoryEntry = new DirectoryEntry();
		using(directoryEntry = new DirectoryEntry(userDN))
            // force password change at next logon
			directoryEntry.Properties["pwdLastSet"].Value = 0; 
	catch (Exception ex)

Users browsing this topic