C# 操作 Active Directory 报出"登录失败: 未知的用户名或错误密码。"
DirectoryEntry entry = new DirectoryEntry(ADPath, userName, password, AuthenticationTypes.None);
return entry;
用以上代码构造出一个entry对象,再利用entry构造出一个DirectorySearcher,利用其搜索出一个DirectoryEntry,但在访问DirectoryEntry对象的Properties属性时,报
异常详细信息: System.DirectoryServices.DirectoryServicesCOMException: 登录失败: 未知的用户名或错误密码。
DirectoryEntry de = GetDirectoryEntryByAccount(sAMAccountName);
if (de != null)
{
string commonName = de.Properties["cn"][0].ToString();//主要出错是这段代码〈〈〈〈〈〈=====
}
以上的ADPath, userName, password 均在LDP.EXE中使用没有问题,但是代码实现中就有问题,不知是哪方面的问题。请指教!!!