错误0x80005000使用Windows提示符在Active Directory中创建用户

时间:2015-05-27 19:10:15

标签: c# active-directory directoryservices

所以我有以下代码:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
startInfo.FileName = "CMD.exe";
string[] serverNameParts = ServerName.Split('.');
string CN1 = t1.Text, CN2 = "Users";
string pwd = t2.Text;
startInfo.Arguments = "/c dsadd user " + "CN=" + CN1 + ",CN=" + CN2 +",";

for (int i = 0; i < serverNameParts.Length; i++)
{
    startInfo.Arguments = startInfo.Arguments + "DC=" + serverNameParts[i] + ",";
}
startInfo.Arguments = startInfo.Arguments + " & ping www.google.com /t";
process.StartInfo = startInfo;
process.Start();

我使用了ping,所以我可以看到为什么它不会创建一个帐户。 我得到的是这个错误: 错误代码= 0x80005000 输入dsadd /?寻求帮助。

我无法弄清楚这里可能出现什么问题,我检查了最后的字符串,它看起来完全正常,我甚至将它输入到promt中,一切都运行得很好,但是当我成功时它就赢了在我的应用中使用它。有什么方法可以解决这个问题吗?我认为它与权限有关,但我无法想出让我的程序运行管理员cmd的权利。

0 个答案:

没有答案