centem
asked on
Account Expiration with System.DirectoryServices.AccountManagement
Hi, I'm creating an acount using the System.DirecotryServices.A ccountMang ement. All works except for the expiration date on the accounts does not reflect what typed into the textbox. Below is the code. How can I get the account expiration date onto the account. Thanks.
PrincipalContext AddContext = new PrincipalContet(ContextTyp e.Domain, "domain.com", context);
UserPrincipal usr = new UserPrincipal(AddContext, newuser, "password", true);
usr.GivenName = fn;
usr.MiddleName = mi;
usr.Surname = ln;
usr.SamAccountName = newuser;
usr.UserPrincipalName = newuser + "@domain.com";
usr.AccountExpirationDate = Convert.ToDateTime(txtVarD ate.Text);
PrincipalContext AddContext = new PrincipalContet(ContextTyp
UserPrincipal usr = new UserPrincipal(AddContext, newuser, "password", true);
usr.GivenName = fn;
usr.MiddleName = mi;
usr.Surname = ln;
usr.SamAccountName = newuser;
usr.UserPrincipalName = newuser + "@domain.com";
usr.AccountExpirationDate = Convert.ToDateTime(txtVarD
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. Although its behind by two days. For example, when I set it to 2012-05-05 I actually get 2012-05-03. How can I fix that? Thanks.
This article should help to explain the discrepancy : http://www.rlmueller.net/A ccountExpi res.htm
http://msdn.microsoft.com/