Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The LDAP server is unavailable

Tags:

c#

asp.net

ldap

I'm a total newbie to this

Trying to connect to an ldap server with PrincipalContext. I have tried all solutions on this site to no avail.

Things I've tried:

PrincipalContext insPrincipalContext = 
   new PrincipalContext(ContextType.Domain);

PrincipalContext insPrincipalContext = 
   new PrincipalContext(ContextType.Domain, "ldap://localhost:389/dc=maxcrc,dc=com");

PrincipalContext insPrincipalContext = 
   new PrincipalContext(ContextType.Domain, "maxcrc.com");

All give the same result:

LDAP server not available

Only ContextType.Machine works basically.

Not sure if my LDAP server is set up correctly:

  • Host: localhost
  • Port: 389
  • Base DN: dc=maxcrc,dc=com
  • URL: ldap://localhost:389/dc=maxcrc,dc=com

Testing with Softerra LDAP Browser

Any tutorials from start to finish will be much appreciated...

like image 721
Anarchy101 Avatar asked Jan 23 '13 12:01

Anarchy101


People also ask

Can't connect to LDAP server?

Cannot contact LDAP Server: If you receive a "Cannot connect to the LDAP Server" error message, try to connect using the LDAP Server IP address. You should also check to be sure the LDAP machine is running. Another possibility is that the SSL certificate files are not valid.

What is a LDAP server?

What is LDAP? LDAP (Lightweight Directory Access Protocol) is an open and cross platform protocol used for directory services authentication. LDAP provides the communication language that applications use to communicate with other directory services servers.


1 Answers

I have been facing the same issue and I found a solution.

I'm able to connect easily using following code:

 ADUser_Id = "domainName\\username"; //make sure user name has domain name.
 Password = "xxxx";
var context = new PrincipalContext(ContextType.Domain,"server_address", ADUser_Id,Password);
/* server_address = "192.168.15.36"; //don't include ldap in url */
like image 196
Ravi Anand Avatar answered Sep 22 '22 16:09

Ravi Anand