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 I want to do this in order to create a Windows user and set a password that has never expired, But I do not know how to do this?
source share