Jump to content

Recommended Posts

Posted

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

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...