I seem to have lost my trusty script that renames Macs and joins them to AD so I've had to re-make it.
Anyway, it's all nice and shiny now and it may come in handy for you since I've made it rather generic. You can check it out at http://www.edugeek.net/wiki/index.ph...tive_Directory
Feel free to post feedback and extend the script if needs be.
Last edited by mac_shinobi; 5th August 2009 at 06:28 PM.
Yeah.. the wiki has gone stoopid... I'll post the script here too:
Code:#!/bin/bash # This script is intended to change the computer name and (optionally) join # the computer to Open Directory and Active Directory and enable AD # authentication. # # This script must be run as root! It's not my fault if it b0rks your shiny # new Mac either! # # Created by: Ric Charlton, 29/07/2009 # Check if root if test $USER != 'root'; then echo You must be root to run this script!!! exit 666 fi # Set variables echo Enter new computer name: read NEWCOMPUTERNAME echo Enter new domain name: read NEWDOMAINNAME NEWHOSTNAME=$NEWCOMPUTERNAME.$NEWDOMAINNAME echo Do you want to join Open Directory? [y/n] read joinLDAP if test $joinLDAP = 'y'; then echo Enter LDAP server fqdn: read LDAPSERVER echo Enter LDAP directory admin username: read LDAPUSERNAME fi echo Do you want to join Active Directory? [y/n] read joinAD if test $joinAD = 'y'; then echo Enter AD directory admin username: read ADUSERNAME echo Enter local admin username: read LOCALUSERNAME echo Is this a mobile computer? [y/n] read isMobile if test $isMobile = 'y'; then MOBILEMAC=enable; else MOBILEMAC=disable; fi fi # Change hostname echo Configuring hostname... hostname $NEWHOSTNAME scutil --set HostName $NEWHOSTNAME echo Done configuring hostname # Change computername (Bonjour and AppleTalk name) echo Configuring computername... systemsetup -setcomputername $NEWCOMPUTERNAME echo Done configuring computername if test $joinLDAP = 'y'; then # Bind to LDAP server echo "Binding to LDAP server (you will be prompted for the direcotry admin password)..." dsconfigldap -a $LDAPSERVER -n $LDAPSERVER -c $NEWCOMPUTERNAME -u $LDAPUSERNAME echo Done binding to LDAP server fi if test $joinAD = 'y'; then # Bind to AD and enable AD authentication echo "Binding to Active Directory and enabling AD authentication (you will be prompted for the AD admin password)..." ##¬¨‚Ä†Modify DirectoryService.plist defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" Active ##¬¨‚Ä†Bind to AD dsconfigad -a $NEWCOMPUTERNAME -u $ADUSERNAME -domain $NEWDOMAINNAME -mobile $MOBILEMAC -useuncpath enable ## Add authentication search path dscl /Search -create / SearchPolicy CSPSearchPath dscl /Search -append / CSPSearchPath "Active Directory/All Domains" ## Add contacts search path dscl /Search/Contacts -create / SearchPolicy CSPSearchPath dscl /Search/Contacts -append / CSPSearchPath "Active Directory/All Domains" echo Done configuring AD # Kill DirectoryService - it restarts automatically killall DirectoryService fi
barrystone (6th August 2009)
Thanks for reply
I will give it a go
There are currently 1 users browsing this thread. (0 members and 1 guests)