OPNsense Forum

English Forums => 25.1, 25.4 Production Series => Topic started by: gdur on February 01, 2025, 03:59:08 PM

Title: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: gdur on February 01, 2025, 03:59:08 PM
Just upgraded to 25.1 and ran into this problem. LDAP bind error [; Can't contact LDAP server].
I have tested the LDAP connection prior to the update and it was still operational.
This happened on 2 machines, one after the other. Where #2 is for backup purposes.
Using the OPNSense tester results in:
The following input errors were detected:
    Authentication failed.
    error: User DN not found

I checked the connectivity from the console:
nc xx.xx.x.x 389 -v -w 10 and the response is:Connection to xx.xx.x.x 389 port [tcp/ldap] succeeded!
So what is wrong with the upgrade?
Added on Sunday 2-2-2025:
Forgot to mention that this is related to OpenVPN.
I've created for some users a local password, added local database to instance settings of OpenVPN and these users are now able to login.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: gdur on February 06, 2025, 10:09:48 AM
Just bringing this problem again under attention since there has not been a response thus far.
Is this problem related to https://forum.opnsense.org/index.php?topic=45606.0 (https://forum.opnsense.org/index.php?topic=45606.0)?
It's clear from post 45606.0 that some changes were made regarding the LDAP implementation but possibly I have missed what the consequences are for already existing LDAP users. Do I need to re-create all the existing LDAP users?
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on February 09, 2025, 12:30:01 AM
Same here. Since upgrading to 25.1 LDAP users cannot login anymore with the error message given in this post.

I have already deleted an LDAP user and recreated it. But still cannot login with it.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on March 04, 2025, 10:37:19 PM
Second small update published. So I don't have the feeling this issue is going to get fixed.

@gdur Were you able to solve this somehow?
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: dsvfhiubfdg on March 26, 2025, 12:49:02 PM
i have the same issue...
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on March 26, 2025, 01:32:31 PM
What does your bind DN look like?
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: dsvfhiubfdg on April 02, 2025, 04:11:31 PM
like that: `uid=testing-binder,ou=bindUsers,dc=somename,dc=net`

Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 02, 2025, 04:29:06 PM
Try cn= instead of uid= ...
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: dsvfhiubfdg on April 03, 2025, 03:58:00 PM
well thats wrong, since thats not the bind dn, why should that work, older opnsense versions work with exact same settings. thats not a fix.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 03, 2025, 04:21:40 PM
I know of no directory that uses uid= in a distinguished name. What directory is this? Active Directory uses cn=xyz,ou=...,dc=domain,dc=com. Hence my suggestion.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: passeri on April 04, 2025, 12:16:23 AM
The documentation (https://docs.opnsense.org/manual/how-tos/user-ldap.html) uses cn=
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 08, 2025, 11:41:26 PM
My ldap user is CN=LdapQuery,CN=Users,DC=my,DC=domain,DC=name. That's the same it was before the v25 upgrade. The directory behind is an Active Directory.
The same bind DN works perfectly with other applications authenticating against AD.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: dsvfhiubfdg on April 10, 2025, 02:59:25 PM
Quote from: Patrick M. Hausen on April 03, 2025, 04:21:40 PMI know of no directory that uses uid= in a distinguished name. What directory is this? Active Directory uses cn=xyz,ou=...,dc=domain,dc=com. Hence my suggestion.
Quote from: passeri on April 04, 2025, 12:16:23 AMThe documentation (https://docs.opnsense.org/manual/how-tos/user-ldap.html) uses cn=


its rfc2307bis openldap (slapd) and I think I know best which DN my binduser uses in LDAP, it's not as if opnsense is the first software to be connected via it.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: franco on April 10, 2025, 03:20:22 PM
No LDAP server was ever slap'd in the making of OPNsense.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 10, 2025, 03:34:40 PM
If you can tolerate the "breach" of the password for a short amount of time, configure plain text LDAP over port 389 instead of LDAPS over 636 and use something like:

tcpdump -i <interface> -s0 -n -X port 389

to get a full trace of the conversation. That's what I do when new LDAP deployments don't work for obscure reasons.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 11, 2025, 10:24:50 PM
As far as I understand the capture result the bind is successful, so the ldap user isn't the problem.

However I'm struggling to understand what happens after that other than the disconnect.

IP ending on 1 is Opnsense, 80 is a domain controller. There are more DCs, but for troubleshooting it's the only one I kept active on Opnsense.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 11, 2025, 10:49:52 PM
The LDAP bind should be followed by an LDAP search request, which it did not in your screen shot. Did you try a full authentication or the "tester" in OPNsense?

Maybe something with base DN, LDAP filter or some such ...
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 12, 2025, 11:18:51 AM
Full authentication, so logged out of the web gui and tried to login with an ldap account.

I assume I can rule out a firewall rule anywhere blocking anything if the connection gets established in general. Between Opnsense there's only the packet filter of Opnsense itself and the personal firewall of the Domain controller (which allows LDAP of course).
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 12, 2025, 12:33:49 PM
Hmmm ... can you try the tester? There must be an LDAP search following the bind ...
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 12, 2025, 03:54:31 PM
No, I'm afraid not, used the tester here. I hope the images are still readable, had to resize them in order to attach them.

Not sure if frame nr. 2 is of any significance.

A note about the configuration page of the LDAP server: The "select" button next to "Authentication containers" works fine and shows me all the entries I'd expect.

I can only emphasize this worked flawlessly until the v25 upgrade. I was used to logging in only with my domain/ldap account, not the local root account. I initiated the upgrade to v25 and right after the reboot I couldn't login anymore.
There were also no changes to the domain controllers.

Just a note: There's also an Apache webserver in the same subnet using LDAP auth for some resources with equal settings - works fine.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 12, 2025, 05:45:12 PM
That looks like some extra characters in the search string - to which the server probably correctly responds with "NO_OBJECT". Weird.

I'm sorry, I only run LDAP for OpenVPN without issues so I cannot reproduce it easily. I just happen to know LDAP a bit from years of experience with AD, so I chimed in.

I'd file a bug on github.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 12, 2025, 10:09:42 PM
Thanks for trying to help!

Probably not a bad idea. I opened a bug report: https://github.com/opnsense/core/issues/8541
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: dsvfhiubfdg on April 14, 2025, 12:47:34 PM
its not a new deployment, its already used in production on older 24.7 releases.

I planed to upgrade and thats the point where i cant because of an update that bricked something, and i am not alone.

With no encryption I cannot reproduce the problem with our test ldap, hopefully it is clear that you should not use it productively, the productive ldap is LDAPS only.

(https://i.imgur.com/gl0hr9U.png)

with LDAPS im getting exactly the same on our testing LDAP which speaks LDAPS as well as LDAP.
2025-04-14T10:46:48    Error    opnsense    LDAP bind error [; Can't contact LDAP server]

What do i need to provide so we can debug this more?
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 14, 2025, 10:03:00 PM
I got it to work by emptying the extended query field.

See the linked bug report. It's being further discussed there.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 15, 2025, 12:23:54 AM
Now THAT's interesting ... thanks for keeping us informed.

I just had to check - I do use extended query and I do not experience your problem. I use it to limit access to a particular group by matching "memberOf". But I did not put an outer pair of parentheses in the field. Want to try using just "objectClass=person"?
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: franco on April 15, 2025, 07:56:43 AM
Parenthesis shouldn't matter here as sooner or later the query parts are wrapped in extra parenthesis in order to construct the full search string. Apparently case also wasn't the issue so this remains a bit elusive...


Cheers,
Franco
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: RosIsTer on April 15, 2025, 11:47:42 PM
Good ideas.

I did some further tests. Apparently whatever I enter in there will not work if there are outer parenthesis.

So this will not work:
(&(condition1)(condition2))

This does work:
&(condition1)(condition2)
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 16, 2025, 10:19:59 AM
If the OPNsense code adds another pair of outer parentheses, probably "(filter)" is valid while "((filter))" is not. I could not find a full spec, i.e. EBNF just right now. The LDAP RFC hand simply refers to X.500 and ASN.1, unfortunately, and I'm not going down that rabbit hole just now.
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: franco on April 16, 2025, 11:01:44 AM
I made a note here because some claims regarding wrong defaults and unclear documentation were made... https://github.com/opnsense/core/issues/8541#issuecomment-2808614328
Title: Re: OpenVPN 25.1 -> LDAP bind error [; Can't contact LDAP server] after upgrade.
Post by: Patrick M. Hausen on April 16, 2025, 11:21:19 AM
I added some explanation to what is probably going on.