Ric_ Posted July 29, 2009 Posted July 29, 2009 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.php/Changing_the_computername_and_joining_Open_Directory_and_Active_Directory Feel free to post feedback and extend the script if needs be.
mac_shinobi Posted August 5, 2009 Posted August 5, 2009 (edited) Deadlink? You can tell its one of those days as Im having one of those as well haha:rolleyes: http://www.howtomac.co.uk/?p=82 Edited August 5, 2009 by mac_shinobi
Ric_ Posted August 6, 2009 Author Posted August 6, 2009 Yeah.. the wiki has gone stoopid... I'll post the script here too: #!/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 1
barrystone Posted August 6, 2009 Posted August 6, 2009 Ric Thanks for reply I will give it a go Regards Barry
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now