c# - Generate password for AD user account that meets complexity policy -
i need create ad
users automatically. problem is, making sure generated password meets password policy of ad
. don't know policy be, there way determine @ runtime? i'm using can see complexity static length=16
, 4 non-alphanumeric chars
, might not work. looking way password policy ad
generated passwords correct.
userprincipal = new userprincipal(oprincipalcontext); up.samaccountname = userid; up.setpassword(system.web.security.membership.generatepassword(16, 4)); up.enabled = false; up.expirepasswordnow(); up.save();
this i'm using. i'm getting password properties using directoryentry/ldap
, use create password.
directoryentry child = new directoryentry("ldap://machine/dc=domain,dc=com"); int minpwdlength = (int)child.properties["minpwdlength"].value; int pwdproperties = (int)child.properties["pwdproperties"].value;
use properties when creating password.
userprincipal = new userprincipal(oprincipalcontext); up.samaccountname = userid; up.setpassword(system.web.security.membership.generatepassword(minpwdlength, pwdproperties)); up.enabled = true; up.expirepasswordnow(); up.save();
Comments
Post a Comment