Last active
May 23, 2024 21:38
-
-
Save rbuzzell/438314507e8383cde86d399bcbc67e0e to your computer and use it in GitHub Desktop.
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 | |
| # Functions | |
| doBind(){ | |
| echo "Attempting AD bind" | |
| ntpdate -u ad.domain.fqdn | |
| dsconfigad -a "$(scutil --get ComputerName | cut -c1-15) -u $bindServiveAccount -p "$password" -localhome anable -useundpath disable -alldomains enable -groups "$adminGroupHere" -mobile enable -mobildconfirm disable -doman ad.domain.fqdn -force -passinterval 0 -ou "OU=Path,OU=To,OU=OU,OU=In,DC=ad,DC=domain,DC=fqdn" | |
| } | |
| # Remove existing object to remove bind conflicts on local machine | |
| removeBind(){ | |
| echo "Removing old bind" | |
| dsconfigad -force -remove -u $bindServiceAccount -p '$password' | |
| } | |
| # Set hostname in a way that sets hostname attribute required for AD CS. | |
| # | |
| # I don't know which one specifically is required, but changing them all | |
| # started to set the `dNSHostName` in the AD object when just `ComputerName` | |
| # didn't do it, and largely this is harmless to set all of. | |
| setHostname(){ | |
| echo "Setting hostname for AD bind" | |
| scutil --set ComputerName $1 | |
| scutil --set Hostname $1 | |
| scutil --set LocalHostName $1 | |
| } | |
| setHostname | |
| removeBind | |
| doBind |
Author
Author
I think I have a typo in here and the NTP command needs an update. I no longer have macOS that I need to bind to AD to test that with.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should be enough to programaticaly bind macOS to AD if you're still doing that, you'll need to adjust variables for your environment though.
Takes the hostname as an argument, you can pass this from the command line or as a JAMF argument.