Link to home
Start Free TrialLog in
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?
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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;