+ Post New Thread
Results 1 to 5 of 5
Mac Thread, Script to rename Macs and join them to OD/AD in Technical; I seem to have lost my trusty script that renames Macs and joins them to AD so I've had to ...
  1. #1

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,596
    Thank Post
    109
    Thanked 764 Times in 595 Posts
    Rep Power
    181

    Thumbs up Script to rename Macs and join them to OD/AD

    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.

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,691
    Thank Post
    352
    Thanked 796 Times in 715 Posts
    Rep Power
    347
    Deadlink?

  3. #3

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,763
    Thank Post
    3,273
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365
    Quote Originally Posted by kmount View Post
    Deadlink?
    You can tell its one of those days as Im having one of those as well haha

    http://www.howtomac.co.uk/?p=82
    Last edited by mac_shinobi; 5th August 2009 at 06:28 PM.

  4. #4

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,596
    Thank Post
    109
    Thanked 764 Times in 595 Posts
    Rep Power
    181
    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

  5. Thanks to Ric_ from:

    barrystone (6th August 2009)

  6. #5

    Join Date
    Feb 2008
    Location
    Gloucester
    Posts
    36
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Thumbs up

    Ric

    Thanks for reply

    I will give it a go


    Regards

    Barry

SHARE:
+ Post New Thread

Similar Threads

  1. File Rename Script
    By Jackd in forum How do you do....it?
    Replies: 2
    Last Post: 19th November 2008, 07:39 AM
  2. Can't Log on or join Network
    By steve_nfi in forum Wireless Networks
    Replies: 13
    Last Post: 10th June 2008, 08:08 AM
  3. Replies: 4
    Last Post: 23rd March 2006, 06:27 AM
  4. What union to join??
    By edie209 in forum General Chat
    Replies: 29
    Last Post: 21st March 2006, 10:28 AM
  5. Please join in...
    By Dos_Box in forum General Chat
    Replies: 16
    Last Post: 30th September 2005, 09:06 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •