I tried to search and use command line to test connection to LDAP server but it throw error "Cannot connect to the LDAP server" even at my local computer
I use visual studio to debug code at my local computer and it connect successfully?
So How to connect to LDAP serrver using cmd for windows 10?
Cmd error:
ldapsearch -x -h LDAP://adserverxx.xx -p 389 -D "cn=ldap,dc=test" -w passxx "objectclass=*"
Code C# run ok and successfully authenticated by using Visual Studio, run in my local computer (error Network path not found in hosted server)(ASP.NET)
bool bSucceeded;
string strAccountId = "ldap";
string strAccountPas = "inxxx";
string strError = "";
DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://serveraddxx:389", strAccountId, strAccountPas);
using (DirectorySearcher adsSearcher = new DirectorySearcher(directoryEntry))
{
//adsSearcher.Filter = "(&(objectClass=user)(objectCategory=person))";
adsSearcher.Filter = "(sAMAccountName=" + strAccountId + ")";
try
{
SearchResult adsSearchResult = adsSearcher.FindOne();
bSucceeded = true;
string strAuthenticatedBy = "Active Directory";
strError = "User has been authenticated by Active Directory.";
}
catch (Exception ex)
{
// Failed to authenticate. Most likely it is caused by unknown user
// id or bad strPassword.
strError = ex.ToString();
}
finally
{
directoryEntry.Close();
}
}
P/S: We have problem connect to ldap from our hosted server (web application) today (yesterday it's ok), it only throw exception "Network path not found".