Solved

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

Posted on 2010-09-14
4
937 Views
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?

Cheers,
0
Comment
Question by:KazooSoft
  • 2
4 Comments
 
LVL 4

Author Comment

by:KazooSoft
ID: 33670499
I have figured the password expiry


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


But not the "User must change password at logon"
0
 

Expert Comment

by:shahbaz-ahmad
ID: 33670569
Try this. This is an example of VB script.


objUser.Put "pwdLastSet", 0
objUser.SetInfo

Open in new window

0
 

Expert Comment

by:shahbaz-ahmad
ID: 33670589
Cont from my previous post:

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

Cheers,
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 33670606
try the following:newUser.Properties["pwdLastSet"].Value = 0;newUser.CommitChanges();(http://geekswithblogs.net/mhamilton/archive/2005/10/20/57486.aspx)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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