From Host, Can’t Connect to OpenLDAP server installed on VM

Posted on

A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about From Host, Can’t Connect to OpenLDAP server installed on VM was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, centos, ldap, openldap, .

I have created an OpenLDAP install on a CentOS Hyper-V VM hosted on my Windows 10 laptop. Using Apache Directory Studio (on the VM), I have created a connection, setup up the domain, and added Groups and People.

The IP address of the VM is On my host machine, if I ping that IP, I get back a response. If I then shut down the VM and ping the IP again, this time I get no response. Power the VM back up, ping, get a response. So it looks like the IP is good.

So far, all is well. However…

First, I’ve installed Apache Directory Studio on my host machine as well. But when I try to create the same connection, I get

The connection failed -unable to connect.


The connection failed
 - Unable to connect
  java.lang.Exception: Unable to connect
    at org.eclipse.jface.operation.ModalContext$

  Unable to connect

Second, I need to create a small little c# console app as a PoC to connect to the server and authenticate a user. Oddly, I can connect to the server just fine using:

LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("");
LdapConnection ldapConnection = new LdapConnection(ldi);

But when I try to authenticate a user:

ldapConnection.AuthType = AuthType.Basic;
ldapConnection.SessionOptions.ProtocolVersion = 3;
NetworkCredential nc = new NetworkCredential("ccrookston", "password", "");

I get:

The LDAP server is unavailable.

Stack Trace:

   at System.DirectoryServices.Protocols.LdapConnection.Connect()
   at System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential)
   at System.DirectoryServices.Protocols.LdapConnection.Bind(NetworkCredential newCredential)
   at OpenLDAP.Program.Main(String[] args) in C:UserscaseycDocumentsVisual Studio 2017ProjectsOpenLDAPProgram.cs:line 33

I’m not sure where to start troubleshooting this. Is it a configuration within CentOS on the VM? Is it a Hyper-V configuration? Or something on my Windows Host machine, like a firewall setting?


Got it.
In the firewall (using the GUI) I added ports:

389 – tcp
389 – udp

It seems to need both.

Leave a Reply

Your email address will not be published. Required fields are marked *