By: Vreixo Luis Gonzalez Caneda user 18 May 2021 at 3:03 p.m. CDT

7 Responses
Vreixo Luis Gonzalez Caneda gravatar
I would like to connect to opendj externally in order to use a tool like jxplorer for a installation with docker via py-gluu-compose. Using command for docker container works, like this: docker exec ldap /opt/opendj/bin/ldapsearch -h localhost -p 1636 -Z -X -D "cn=directory manager" -w "PASSWORD" -b "ou=people,o=gluu" "gluustatus=active" But the problem is to connect from outside the container where it does not connect, of course after exposing ports. I'm getting: ldap_start_tls: Can't contact LDAP server (-1) ldap_sasl_interactive_bind_s: Can't contact LDAP server (-1) Could you describe the procedure to connect from outside the container? Should I use a certificate in order to connect? Thank you very much

By Aliaksandr Samuseu staff 18 May 2021 at 3:13 p.m. CDT

Aliaksandr Samuseu gravatar
Hi. You use [this doc](https://gluu.org/docs/gluu-server/4.2/installation-guide/install-docker/) to setup your Docker-based environment, right?

By Vreixo Luis Gonzalez Caneda user 18 May 2021 at 3:17 p.m. CDT

Vreixo Luis Gonzalez Caneda gravatar
Yes, exactly, we have followed those instructions but we didn't see how to connect externally there

By Michael Schwartz Account Admin 18 May 2021 at 3:36 p.m. CDT

Michael Schwartz gravatar
I wouldn't expose the ports publicly for security reasons. Normally I use an SSH tunnel to do this. Can you run ssh and then expose port 22?

By Vreixo Luis Gonzalez Caneda user 18 May 2021 at 4:10 p.m. CDT

Vreixo Luis Gonzalez Caneda gravatar
I think that I was not clear in my question. WIth "exposed" I mean that I have bind port from docker container to localhost. My issue is that I can't connect from the machine running the docker containers to opendj docker container ldap service using ldapsearch. Connecting directly to the IP after doing a docker inspect does not work either. I guess that the issue might be in the connection options for ldapsearch that should be different from outside the container but I didn't found the information. Once I'm able to connect to the opendj container I will indeed do an SSH tunnel from my computer to configure the tool.

By Aliaksandr Samuseu staff 19 May 2021 at 4:55 p.m. CDT

Aliaksandr Samuseu gravatar
Sorry for the delayed answer. Seems like it may not be as easy as I thought, after all.. The problem with Jxplorer is this: ``` javax.naming.CommunicationException: simple bind failed: 192.168.238.175:7636 [Root exception is javax.net.ssl.SSLHandshakeException: No subject alternative names matching IP address 192.168.238.175 found] ``` Apparently it comes down to how certificate LDAP server uses inside container is composed, as SANs take precedence over Subject/CN field in it, and the only DNS name defined in SANs field there is "ldap" - what makes sense only inside container. Frankly, this is mostly client's (Jxplorer) issue, as it just rejects certificate, without giving user a choice. For example, you still can use `ldapsearch` tool to search inside container via your exposed port, if you specify `-X` argument that cancles thorough certificate verification. So if you have some other LDAP GUI browser that allows the same should do the trick.

By Aliaksandr Samuseu staff 19 May 2021 at 4:58 p.m. CDT

Aliaksandr Samuseu gravatar
...and I had an idea instantly. So I went to `/etc/hosts` file on the machine from which I run Jxplorer, and I added a line there, a mapping like this: ``` 192.168.238.175 ldap ``` ..where `192.168.238.175` is ip address of the machine where Docker runs and where the LDAP container's port was exposed. Then in Jxplorer, I used "ldap" as "Host" and my exposed port as "Port" when setting up a connection - and I'm in there. Two hours of wasted time on trying something totally different and way more complex..

By Vreixo Luis Gonzalez Caneda user 20 May 2021 at 10:49 a.m. CDT

Vreixo Luis Gonzalez Caneda gravatar
Thank you very much Aliaksandr for your help, indeed with the /etc/hosts adaptation it's working perfectly with JXplorer for me too from my development machine. Regarding the ldapsearch thing it turns out that the ldapsearch packed in ldap-tools in ubuntu is different than the one that you have packaged with opendj, and copying the binaries from your container it does work from the machine running docker too. I'll close the ticket as all it's solved