的DirectoryServices - “网络登录失败未知的用户名或密码错误”用户名、错误、密码、网络

2023-09-08 13:28:41 作者:万人中央我独殇

我构建一个小图书馆可用于查询Active Directory资源。我测试过它之前,它的作品,因为我希望它。

I'm building a little library that can be used to query Active Directory resources. I've tested it out before and it works as I expect it to.

问题是我创建了一个全新的VMWare虚拟计算机上安装Windows Server 2003,创建的域,增加了一些虚拟对象,现在当我尝试运行该应用程序我得到的错误:

The problem is I have created a brand new VMWare virtual computer with Windows Server 2003 installed, created the domain, added some dummy objects and now when I try to run the application I get the error:

网络登录失败未知的用户名或密码错误。

"Network logon failure unknown user name or bad password".

//Example 1: Find all users in Active Directory. Be sure your LDAP connection string is correct.            
string ldapConnection = @"LDAP://sergio-j9i2vccv/dc=contoso,dc=com";
string username = "Administrador"; //I'm using a spanish version of WS2003.
string password = String.Empty;

UserFinder userSearcher = new UserFinder(ldapConnection, username, password);
try
{
    var users = userSearcher.FindAllUsers();

    foreach (var user in users)
    {
        Console.WriteLine(user.Name);
        Console.WriteLine(user.Path);
    }
}
catch (Exception e)
{
    Console.WriteLine(e.Message);
}   

事实:

在我的笔记本电脑主机可以ping我的虚拟服务器,反之亦然。 在该域正确地创建。 在该应用程序已在另一个虚拟机进行测试时运行正常。

我唯一的想法是,不知怎的,我需要给权限的Administrator帐户(一个我选择使用)来查询域。

My only idea is that somehow I need to give permission to the Administrator account (the one I chose to use) to query the domain.

我如何做到这一点?

或者我甚至可以创建一个全新的用户,并赋予是查询域的权限。

Or I might even create a brand new user and give that permission to query the domain.

有什么建议?我敢肯定有一个选择的地方我一定要实现。

Any suggestions? I'm sure there's an option somewhere I have to enable.

感谢您!

修改!

我刚安装了.NET Framework 4的Server 2003虚拟机上运行的应用程序从那里。它运行得很好。

I just installed the .NET Framework 4 on the Server 2003 virtual machine and ran the application from there. It runs flawlessly.

因此​​,与新知识,这可能是导致此错误?

So with that new knowledge, what could be causing this error?

推荐答案

我只是觉得,你的管理员不能有一个空密码。尝试使用一个有效的passowrd(遵守密码规则)。

I just think, that your administrator can't have an empty password. Try with a valid passowrd (respecting the password rules).

JP