Avatar of Dallas Smetter
Dallas SmetterFlag for United States of America

asked on 

Using userAccountControl to set *both* PASSWD_CANT_CHANGE and DONT_EXPIRE_PASSWORD

I know how to use one or the other, but how can I achieve both?
Active DirectoryWindows Server 2008Powershell

Avatar of undefined
Last Comment
Steven Carnahan
Avatar of Contigo1
Contigo1

You should be able to set both in AD users and computers by right clicking on the user going to properties > Account

Then selecting the User cannot change password and Password never expires settings.
SOLUTION
Avatar of Steven Carnahan
Steven Carnahan
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Dallas Smetter

ASKER

I need to do this for nearly a quarter million users, so I can't do it manually.

I'll try pony10us's suggestion and post back.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Dallas Smetter

ASKER

And we can also, in this situation, use the userAccountControl setting to ensure that student passwords never expire while applying a GPO so that it can't be changed ;-)
Just for reference using what I provided you have many other settings available but I only gave you the ones you requested.  Here are the most common settings:

const int UF_ACCOUNTDISABLE = 0x0002;
const int UF_PASSWD_NOTREQD = 0x0020;
const int UF_PASSWD_CANT_CHANGE = 0x0040;
const int UF_NORMAL_ACCOUNT = 0x0200;
const int UF_DONT_EXPIRE_PASSWD = 0x10000;
const int UF_SMARTCARD_REQUIRED = 0x40000;
const int UF_PASSWORD_EXPIRED = 0x800000;

all you have to do is add the ones you want to this line:

int userControlFlags = UF_PASSWD_NOTREQD + UF_DONT_EXPIRE_PASSWD;
Windows Server 2008
Windows Server 2008

Windows Server 2008 and Windows Server 2008 R2, based on the Microsoft Vista codebase, is the last 32-bit server operating system released by Microsoft. It has a number of versions, including including Foundation, Standard, Enterprise, Datacenter, Web, HPC Server, Itanium and Storage; new features included server core installation and Hyper-V.

86K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo