How does the userAccountControl property work in AD?
Let’s say I want to create a new user account and set it to enabled (it’s disable by default), and also set the ‘password never expires’ option to true. I can do something like this and it works:
//newUser is a DirectoryEntry object
newUser.Properties["userAccountControl"].Value = 0x200; // normal account
newUser.Properties["userAccountControl"].Value = 0x10000; //password never expires
Normally, I would think the second line would wipe the first one out, but it doesn’t. How does that work? Can I combine them in one line? How would I then take away that value if I wanted to have their password expire?
Thanks!
Actually, setting the second value will indeed wipe out the first – point is though, the first is really a bit “unnecessary”…..
And of course you can combine them (and multiple ones, really) into a single value and set it with a single assignment:
Marc