DirectoryServices - “Network logon failure unknown user name or bad password”
I'm building a little library that c开发者_如何学运维an 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?
I just think, that your administrator can't have an empty password. Try with a valid passowrd (respecting the password rules).
JP
精彩评论