Skip to content

fix(conn): parse ldapi:// URLs per RFC 4516#590

Merged
cpuschma merged 1 commit into
go-ldap:masterfrom
c-tonneslan:fix/ldapi-url-host-parsing
May 23, 2026
Merged

fix(conn): parse ldapi:// URLs per RFC 4516#590
cpuschma merged 1 commit into
go-ldap:masterfrom
c-tonneslan:fix/ldapi-url-host-parsing

Conversation

@c-tonneslan
Copy link
Copy Markdown
Contributor

The unix socket path for `ldapi://` belongs in the host component, percent-encoded; the path is reserved for a DN. `net/url` rejects `%2F`-encoded hosts as invalid, so `DialURL` never accepted the spec-compliant `ldapi://%2Fvar%2Frun%2Fldapi` form and silently dropped through to `/var/run/slapd/ldapi` instead.

Added a small `parseLDAPURL` that splits and decodes the host for the `ldapi` scheme, then defers to `net/url` for everything else. The legacy `ldapi:///path` form still works.

This is a focused fix for the socket-path parsing; DN handling (using the path component as a default SearchBase, per cpuschma's comment on the issue) is left as a separate change.

Closes #564.

The unix socket path for ldapi:// belongs in the host component,
percent-encoded; the path component is reserved for a DN. net/url
rejects %2F-encoded hosts as invalid, so DialURL never accepted the
spec-compliant ldapi://%2Fvar%2Frun%2Fldapi form and silently fell
through to /var/run/slapd/ldapi instead.

Add a thin parseLDAPURL that pre-extracts and decodes the host for
the ldapi scheme, then defers to net/url for everything else. The
older ldapi:///path form still works.

Closes go-ldap#564.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
@cpuschma cpuschma merged commit e632004 into go-ldap:master May 23, 2026
4 checks passed
@cpuschma cpuschma self-assigned this May 23, 2026
@cpuschma cpuschma added bug enhancement go Pull requests that update go code labels May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug enhancement go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ldapi:// scheme handling incorrect

2 participants