Here is my code:
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() });
}
}
And what i want to do is to create a windows user and set the password never expired ,
But i do not know how to do this ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…