110,534
社区成员
发帖
与我相关
我的任务
分享
void CreateUser(string userName, string password)
{
PrincipalContext context = new
PrincipalContext(ContextType.Machine);
UserPrincipal newUser = new UserPrincipal(context, userName, password, true);
newUser.Save();
GroupPrincipal group = new GroupPrincipal(context, "Administrators");
group.Members.Add(newUser);
group.Save();
}