Skip to content

feat: implement RFC2782 SRV record discovery support - #638

Closed
cpuschma wants to merge 2 commits into
go-ldap:masterfrom
cpuschma:feature/srv-records
Closed

cpuschma wants to merge 2 commits into
go-ldap:masterfrom
cpuschma:feature/srv-records

Conversation

@cpuschma

@cpuschma cpuschma commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

This PR adds basic support for resolving LDAP servers through SRV records, following the specifications of RFC2782 and adds a new public function LookupSRV to obtain available records by hand.

ldap.DialURL("ldap://srv.example.com", DialWithSRVResolver(nil))

It adds a new DialOpt, so it's use is optional and disabled by default. By default Go's net.DefaultResolver is used, but a custom resolver can be used too.

Closes #329.

@cpuschma cpuschma added enhancement go Pull requests that update go code labels Sep 28, 2026
@cpuschma
cpuschma marked this pull request as ready for review September 28, 2026 21:15
Comment thread v3/conn.go
// DialWithSRVDiscovery makes DialURL resolve the host through DNS SRV records
// (RFC 2782) and connect to the returned targets in RFC 2782 order until one
// connection succeeds. The service name is derived from the URL scheme
// (_ldap._tcp for ldap://, _ldaps._tcp for ldaps://) and the port from the SRV

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, neither Active Directory nor FreeIPA maintain _ldaps._tcp.example.com SRV records. For clients that want to use port 636 with tls-on-connect, the conventino is to a lookup for _ldap._tcp.example.com and ignore the port number in the SRV record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server discovery by SRV record?

2 participants