日期:2014-05-17  浏览次数:20492 次

关于用C#设置windows域用户密码的异常,在线等。。。
直接上源码

C# code

            DirectoryEntry newEntry = new DirectoryEntry("LDAP://192.168.1.66:389/CN=003291,cn=Users,DC=demo,DC=com", "Administrator", "dykjsoft");
            //newEntry.Password = "abc003291";
            //newEntry.Properties["userPassword"].Value = "abc003291";
            newEntry.Invoke("SetPassword", new object[] { "abc003291" });
            newEntry.CommitChanges();




cn=003291这个节点是新加的,用管理员帐号连接正常。我很好奇,中间被注释的两种方法为什么都达不到设置密码的效果。。

newEntry对象没发现什么异常,也就是应该是正常连接上的。能获取其节点内相关信息。

CommitChanges()时抛异常 ,异常信息如下:

System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.IO.FileNotFoundException: 文件名、目录名或卷标语法不正确。 (异常来自 HRESULT:0x8007007B) --- 内部异常堆栈跟踪的结尾 --- 在 System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) 在 LdapTest._Default.Button1_Click(Object sender, EventArgs e) 位置 D:\My Documents\Visual Studio 2005\Projects\LdapTest\LdapTest\Default.aspx.cs:行号 218

------解决方案--------------------
http://blog.csdn.net/yeness/article/details/4165550

以前是这么写的
------解决方案--------------------
继续关注中,大力神 顶起
------解决方案--------------------
高手快来啊,急需求解,再顶一下
------解决方案--------------------
探讨
引用:
http://blog.csdn.net/yeness/article/details/4165550

以前是这么写的


没找到相关代码。。。