Skip to content

Commit

Permalink
net: fixed CldapGetBestLdapController() if no site is defined
Browse files Browse the repository at this point in the history
- fallback to the first known LDAP server
  • Loading branch information
Arnaud Bouchez committed Jan 16, 2025
1 parent b66f8c9 commit 0076e6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.3.9412'
'2.3.9413'
8 changes: 6 additions & 2 deletions src/net/mormot.net.ldap.pas
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function CldapGetDefaultLdapController(
/// pickup the preferred LDAP 'server:port' of a set of LDAP servers
// - will send CLDAP NetLogon messages to the LdapServers to retrieve
// TCldapDomainInfo.ClientSite then request the DNS for the LDAP of this site
// - if no site is defined, fallback to the first known LDAP server
// - as used by CldapGetLdapController() and CldapMyLdapController()
function CldapGetBestLdapController(const LdapServers: TRawUtf8DynArray;
const DomainName, NameServer: RawUtf8; TimeOutMS: integer = 500): RawUtf8;
Expand Down Expand Up @@ -2568,12 +2569,15 @@ function CldapGetBestLdapController(const LdapServers: TRawUtf8DynArray;
res := DnsServices(n, NameServer);
if res <> nil then
begin
result := res[0];
result := res[0]; // found a matching site
exit;
end;
end;
end;
result := '';
if LdapServers <> nil then
result := LdapServers[0] // if no site is defined, use first server
else
result := '';
end;

function CldapGetLdapController(const DomainName, NameServer: RawUtf8;
Expand Down

0 comments on commit 0076e6f

Please sign in to comment.