论坛首页 编程语言技术论坛

C# 操作 AD 问题

浏览 2074 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-12-21  
大家好。在c#移动组织时遇到下面一个问题,很是棘手啊。网上查了大量资料也没能解决。还请各位帮忙看下。
在下面代码处 就出现
if (!DirectoryEntry.Exists(newLocationPath))
                throw new EntryNotExistException("移动到的位置对象不存在。");

这个异常:
System.Runtime.InteropServices.COMException: 登录失败: 未知的用户名或错误密码。

   在 System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   在 System.DirectoryServices.DirectoryEntry.Bind()
   在 System.DirectoryServices.DirectoryEntry.get_AdsObject()
   在 System.DirectoryServices.PropertyValueCollection.PopulateList()
   在 System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
   在 System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
即使我使用

DirectoryEntry de = new DirectoryEntry("LDAP://domain/OU=....dc=...",
               "domain/username", "pass", AuthenticationTypes.ServerBind);
            string test = de.Properties["cn"][0].ToString();
            DirectoryEntry entry = new DirectoryEntry("("LDAP://domain/OU=another OU....dc=...",
                "domain/username", "pass", AuthenticationTypes.ServerBind);            de.MoveTo(entry);

在MoveTo处也一样会报这个错误。
user和 password这些在客户端工具中都可以正常登录。
还麻烦大家帮忙看下。很急啊。
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics