ローカルWindowsユーザーを作成するためのこのコードがあります
public static bool CreateLocalWindowsAccount(string username, string password, string displayName, string description, bool canChangePwd, bool pwdExpires)
{
try
{
PrincipalContext context = new PrincipalContext(ContextType.Machine);
UserPrincipal user = new UserPrincipal(context);
user.SetPassword(password);
user.DisplayName = displayName;
user.Name = username;
user.Description = description;
user.UserCannotChangePassword = canChangePwd;
user.PasswordNeverExpires = pwdExpires;
user.Save();
//now add user to "Users" group so it displays in Control Panel
GroupPrincipal group = GroupPrincipal.FindByIdentity(context, "Users");
group.Members.Add(user);
group.Save();
return true;
}
catch (Exception ex)
{
LogMessageToFile("error msg" + ex.Message);
return false;
}
}
私は自分のマシンでこれを試しましたが、正常に動作します。しかし、それから私はこれをWindowsサーバーに置きました。あそこにユーザーを作ろうとしました。
最初に「一般アクセス拒否エラー」というエラーが発生したので、ユーザーを管理者にしました
しかし今、私は「ネットワークパスが見つかりませんでした」というエラーを受け取ります
どうすればこのエラーを解決できますか..ありがとう