-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server discovery by SRV record? #329
Comments
I like this suggestion; feel free to pull together a PR. Otherwise I'll leave this hear as an enhancement request. |
Just pinging in here; Active Directory does indeed create SRV records as well. I don't have a FreeIPA to play with at the moment, but I do have a function for the SRV lookups (below). Feel free to use, incorporate into the library, etc. (@x3nb63 can you confirm that the FreeIPA SRV records use the same SRV name? I have no doubt that they don't, as it's an RFC (one of the authors is Paul Vixie himself!), but confirmation is good.) import (
"context"
"fmt"
"net"
"net/url"
"github.com/go-ldap/ldap/v3"
)
// ...
var (
dnsCtx context.Context = context.Background()
)
func srvToUri(records []*net.SRV) (uris []*url.URL, err error) {
var u *url.URL
if records == nil {
return
}
uris = make([]*url.URL, len(records))
for idx, r := range records {
uris[idx] = &url.URL{
Scheme: "ldap",
Host: fmt.Sprintf("%v:%v", r.Target, r.Port),
}
}
return
}
func ldapUriFromSrv(domain string, resolver net.Resolver) (uris []*url.URL, err error) {
var srvRecords []*net.SRV
if resolver == nil {
resolver = net.DefaultResolver
}
if _, srvRecords, err = resolver.LookupSRV(dnsCtx, "ldap", "tcp", domain); err != nil {
return
}
// There is no need to sort/shuffle records according to prio/weight;
// the (net.Resolver).LookupSRV() method does this for us.
if srvUris, dnsErr = srvToUri(srvRecords); err != nil {
return
}
} |
Since I don't find "SRV" with the search function I assume this is not supported?
I do have multiple LDAP servers running my domain - would be really good if the clients could be setup that way.
This is about RFC 2782, while its use with LDAP is better described by DNS SRV Records for LDAP
FreeIPA always creates these records (cause its clients depend on it) and I bet systems such as Active Directory do that as well.
The text was updated successfully, but these errors were encountered: