c# Active Directory Tick "Password Never Expires" and more

Posted on 2010-09-14
Last Modified: 2012-05-10
Hey all im creating accounts in active directory but i need my script to also tick the "Password Never Expires" and untick "User Must Change Their Password on next logon" how do you do this?

Question by:KazooSoft
  • 2

Author Comment

ID: 33670499
I have figured the password expiry

                newUser.Properties["userAccountControl"].Value = 0x10000;

But not the "User must change password at logon"

Expert Comment

ID: 33670569
Try this. This is an example of VB script.

objUser.Put "pwdLastSet", 0


Open in new window


Expert Comment

ID: 33670589
Cont from my previous post:

Default value of pwdLastSet is -1. By assigning value 0, you'll get your desire result.

LVL 42

Accepted Solution

sedgwick earned 500 total points
ID: 33670606
try the following:newUser.Properties["pwdLastSet"].Value = 0;newUser.CommitChanges();(

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now