Bug 13165 - ldb* and samba-tool: automatic round robin between servers
Summary: ldb* and samba-tool: automatic round robin between servers
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.5.12
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-23 14:50 UTC by Marco Gaiarin
Modified: 2020-12-22 10:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Gaiarin 2017-11-23 14:50:02 UTC
In a DM it is needed to set explicitly the '-H' options, in ldb* tools and in samba-tool to a valid DC.
[This can be extended considering, in DC, the ability to point the -H option against the SAM database directly...]

But a domain can have many DC, and some of that can be currently not available (in maintenance, ...), and so script based on that tools can fail, while the domain effectively continue to works as expected.

Would be useful to have in that tool some sort of ''round robin'' or ''fallback'' against DC: eg, that tools determine the list of DCs (a simple DNS query), and choose the ''best and available'' one.


I hope i was clear. Thanks.
Comment 1 Rowland Penny 2020-12-21 22:19:52 UTC
Hi Marco, have you tried '-H ldap://samdom.example.com' 
Where 'samdom.example.com' is your dns domain.
Comment 2 Marco Gaiarin 2020-12-22 10:46:00 UTC
Yes, and this effectively does 'round robin', but not failover: if the DNS query return a DC that is down, the script fail.

An option will be to behave like:

1) choose a DC, possibly in 'smart way' (eg, one in local site)

2) check if it is alive

3) if not, return to 1)

4) connect to it.
Comment 3 Marco Gaiarin 2020-12-22 10:56:41 UTC
In bash, i do:

SITE=$(${LDBSEARCH} -H ldap://${DC} -P -b "CN=Subnets,CN=Sites,CN=Configuration,DC=ad,DC=fvg,DC=lnf,DC=it" "(cn=${LOCALNET})" siteObject | grep '^siteObject: ' | cut -d ' ' -f 2)
# 'host' call does not return always ALL DC, so we put two times local DC, to be sure they get choosed.
${LDBSEARCH} -H ldap://${DC} -P -b "CN=SERVERS,${SITE}" "" dNSHostName | grep '^dNSHostName: ' | tee - | cut -d ' ' -f 2 >> ${TMPDC}
for dc in $(cat ${TMPDC} | sort | uniq -d; cat ${TMPDC} | sort | uniq -u); do
  ${LDBSEARCH} -H ldap://${dc} -P -s one "(*)" > /dev/null 2> /dev/null
  if [ $? -eq 0 ]; then
    DC="$dc"
    break;
  fi
done
LDB_OPTS="-H ldap://${DC} -P"
SAMBAT_OPTS="-H ldap://${DC} -P"