We help IT Professionals succeed at work.

Expire an Active Directory users' account password

Last Modified: 2012-05-05
Is it possible to expire an Active Directory users' account password rather than set the option "User must change password at next logon"?  I'm doing some testing with OWA and need a genuine expired password and can figure out how to expire the password.

Any help would be appreceiated.

Watch Question

password expiration is set through the domain security policy manager ( not the domain controller security policy manager ) under account policy -> password policy.although it will set it for the entire domain not a specific user. I am not sure it is setable on a per user basis.

Brian PiercePhotographer
Awarded 2007
Top Expert 2008

Mark is correct, this is done in the domain security policy. The default is 42 days. You can exempt certian user accounts from  having the password expire by selecting the 'Password does not expire' option in the user account but other than this you cannot set different time periods for different users.
Note that unlike many GPO settinfs different OUs cannot have different password policies - this is a domain level setting.


Would it be possible through a script to reset the password?


Moderator:   Can this question be added to Programming > Languages > Visual Basic > VB Scripting ?

Its handled by the pwdLastSet attribute.

Sorry, I've re-read your request and the link that I posted and realised that the posted link doesn't _quite_ meet the requirement. Expired passwords are detected when the pwdLastSet attribute is either 0 or when the attribute contains a date that is greater than the domain security policy allows.

Unfortunately, pwdlastset uses a special date format involving the number of nano seconds since Jan 1, 1601.
Therefore, to simulate a natural password expiry, you would change an account's pwdlastset to x days in the past. I've found a link [1] that describes the logic but it doesn't use VBscript. There are 86400000 nanoseconds in a day so you could  use that to calculate a date in the past.

[1] http://www.irishdev.com/blogs/jbrennan/archive/2005/09/02/973.aspx
You can use the following scriptlet to populate a selected user's pwdlastset attribute.

DaysAgo = "-45"
dtmAdjusted = DateAdd("d", DaysAgo, Now())

' Find number of seconds since 1/1/1601.
lngSeconds = DateDiff("s", #1/1/1601#, dtmAdjusted)

' Convert the number of seconds to a string
' and convert to 100-nanosecond intervals.
str64Bit = CStr(lngSeconds) & "0000000"
Wscript.Echo "Integer8 value: " & str64Bit

(Thanks to Richard Mueller http://www.rlmueller.net/Programs/DateToInteger8.txt)


ryan~  i'm kind of dump founded when it comes to script writing... how do I associate this script with a user?
This one is on us!
(Get your first solution completely free - no credit card required)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.