Created
May 4, 2017 18:55
-
-
Save diegogslomp/5c9b56f14df23a67570efeaf60d7bc99 to your computer and use it in GitHub Desktop.
Check differences between ldap master and slave(s) searches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #Check differences between ldap master and slave(s) searches. | |
| #Change the `LDAPMASTER` and `BASEDN` variables suitting to your environment. | |
| #Tested on CentOS. | |
| LDAPMASTER="ldapmaster_ip" | |
| LDAPSLAVES=$(host ldap | gawk -F' ' '{print $4}') | |
| BASEDN="ou=Users,dc=DomainComponent,dc=DistinguishedName" | |
| ARGS="(&(uid=${1}))" | |
| [[ $# -eq 1 ]] || { echo 'WARNING: Need one argument (LDAP user id) to search. Exiting!'; exit 1; } | |
| echo -e "INFO: LDAPMASTER\n${LDAPMASTER}" | |
| echo -e "INFO: ANSWERING FOR LDAP \n${LDAPSLAVES}" | |
| LDAPMASTER_SEARCH=$(ldapsearch -x -h "${LDAPMASTER}" -b "${BASEDN}" "${ARGS}") | |
| for host in ${LDAPSLAVES}; do | |
| LDAPSLAVE_SEARCH=$(ldapsearch -x -h "${host}" -b "${BASEDN}" "${ARGS}") | |
| DIFF=$(diff <(echo "${LDAPMASTER_SEARCH}") <(echo "${LDAPSLAVE_SEARCH}")) | |
| [[ ${#DIFF} -eq 0 ]] && echo "INFO: NO DIFF BETWEEN ${LDAPMASTER} AND ${host}"\ | |
| || echo "WARNING: DIFF BETWEEN ${LDAPMASTER} AND ${host} DETECTED!" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment