這裏是我的代碼:設置Windows/AD密碼以便「永不過期」?
using (DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"))
{
DirectoryEntry NewUser = AD.Children.Add(username, "user");
string password = username + "123";
NewUser.Invoke("SetPassword", new object[] { password });
NewUser.CommitChanges();
NewUser.Close();
DirectoryEntry grp;
grp = AD.Children.Find(groupname, "group");
if (grp != null)
{
grp.Invoke("Add", new object[] { NewUser.Path.ToString() });
}
}
,我希望做的是創建一個Windows用戶並設置密碼永不過期, 但我不知道如何做到這一點?
看看這個問題如何查詢,它應該給你一些線索:http://stackoverflow.com/questions/7246945/active-directory-check-if-password-never-expires –