如何在Windows中创建管理员帐户?

时间:2017-07-19 06:31:33

标签: c#

我可以使用以下代码添加访客用户

DirectoryEntry AD = new DirectoryEntry("WinNT://" +
                                Environment.MachineName + ",computer");
            DirectoryEntry NewUser = AD.Children.Add("TestUser1", "user");
            NewUser.Invoke("SetPassword", new object[] { "password" });
            NewUser.Invoke("Put", new object[] { "Description", "Test User from .NET" });
            NewUser.CommitChanges();
            DirectoryEntry grp;

            grp = AD.Children.Find("Guests", "group");
            if (grp != null) { grp.Invoke("Add", new object[] { NewUser.Path.ToString() }); }
            Console.WriteLine("Account Created Successfully...");
            Console.ReadLine();

我应该更改哪些更改以使其成为管理员用户/标准用户?

0 个答案:

没有答案