Skip to content

Instantly share code, notes, and snippets.

@macshome
Last active December 8, 2022 14:37
Show Gist options
  • Save macshome/f815aaf4218f1039fdf32f4ad5ec6470 to your computer and use it in GitHub Desktop.
Save macshome/f815aaf4218f1039fdf32f4ad5ec6470 to your computer and use it in GitHub Desktop.
Simple shell script to lookup service records in an AD domain on macOS.
#!/bin/zsh
zparseopts -E -D -- D:=DOMAIN -domain:=DOMAIN d=DNS -dns=DNS
DOMAIN=$DOMAIN[2]
DNS=$DNS
if [[ -z $DOMAIN ]]; then
echo "adlookupos.sh: Troubleshoot DNS service records needed for AD."
echo "\nUsage: adlookups.sh [-d] [-D domain]"
echo " -D, --domain AD domain to examine"
echo " -d, --dns show the system DNS resolvers\n"
echo " Example: ./adlookups.sh --domain jamf.net"
exit 1
fi
echo "\nChecking service records for domain $DOMAIN \n"
echo "Checking for Kerberos records..."
host -t SRV _kerberos._tcp.$DOMAIN
echo "\nChecking for password server records..."
host -t SRV _kpasswd._tcp.$DOMAIN
echo "\nChecking for LDAP records..."
host -t SRV _ldap._tcp.$DOMAIN
echo "\nChecking for global catalog records..."
host -t SRV _gc._tcp.$DOMAIN
if [[ -n $DNS ]]; then
echo "\n"
scutil --dns
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment