Script to bind to Active Directory (10.7)

This script can be run with Remote desktop to bind multiple computers based on the parameters specified within the script.

Simply select the machines with remote desktop  you wish to join to Active Directory and select unix command. Then amend the script below to your network and paste into the unix box. Then set to run as “root” and send the command. You will then see the result of the script. This script will only run if the machine is currently not bound to Active Directory already.

———————Script Start—————————-

######

#

# Script altered by Ross Hamilton – Howtomac.co.ukedumac.co.uk

# Script originally made by Mike Bombich

# Designed for 10.7 Lion

# Re-edited April – 2012

#

######

#Computer name collected

computerid=`/usr/sbin/scutil –get ComputerName`

 

# Standard parameters

domain=”" # fully qualified DNS name of Active Directory Domain

udn=”" # username of a privileged network user

password=”" # password of a privileged network user

ou=”" # Distinguished name of container for the computer EG; ou=computers,DC=domain,DC=com

 

# Advanced options

alldomains=”" # ‘enable’ or ‘disable’ automatic multi-domain authentication

localhome=”" # ‘enable’ or ‘disable’ force home directory to local drive

protocol=”" # ‘afp’ or ‘smb’ change how home is mounted from server

mobile=”" # ‘enable’ or ‘disable’ mobile account support for offline logon

mobileconfirm=”" # ‘enable’ or ‘disable’ warn the user that a mobile acct will be created

useuncpath=”" # ‘enable’ or ‘disable’ use AD SMBHome attribute to determine the home dir

user_shell=”/bin/bash” # e.g., /bin/bash or “none”

preferred=”-nopreferred” # Use the specified server for all Directory lookups and authentication

# (e.g. “-nopreferred” or “-preferred ad.server.edu”)

admingroups=”" # These comma-separated AD groups may administer the machine (e.g. “” or “APPLE\mac admins”)

 

# Login hook setting — specify the path to a login hook that you want to run instead of this script

 

### End of configuration

 

# Activate the AD plugin

defaults write /Library/Preferences/DirectoryService/DirectoryService “Active Directory” “Active”

plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist

sleep 5
# Bind to AD

dsconfigad -f -a $computerid -domain $domain -u $udn -p “$password” -ou “$ou”
# Configure advanced AD plugin options

if [ "$admingroups" = "" ]; then

dsconfigad -nogroups

else

dsconfigad -groups “$admingroups”

fi

dsconfigad -alldomains $alldomains -localhome $localhome -protocol $protocol \

-mobile $mobile -mobileconfirm $mobileconfirm -useuncpath $useuncpath \

-shell $user_shell $preferred
# Adding search Path

sudo dscl /Search -create / SearchPolicy CSPSearchPath

defaults write /Library/Preferences/DirectoryService/SearchNodeConfig “Search Node Custom Path Array” -array “/Active Directory/All Domains”

Dsconfigad -passinterval 0

———————Script End—————————-

VN:F [1.9.20_1166]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)
You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.

Powered by WordPress | Designed by: 7Graus | Thanks to 7Graus WP Themes
Login

AWSOM Powered