DirectoryServices - “Network logon failure unknown user name or bad password”

好久不见. 提交于 2019-12-11 23:39:16

问题


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.

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);
}   

Facts:

  • My host laptop can ping my virtual server, and vice-versa.
  • The domain is correctly created.
  • The application has run correctly when testing on another VM.

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.

How do I achieve this?

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.

Thank you!


EDIT!

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?


回答1:


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

JP



来源:https://stackoverflow.com/questions/5526569/directoryservices-network-logon-failure-unknown-user-name-or-bad-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!