Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Bind Lion to Active Directory with a shell script #381009
    ptrondsen
    Participant

    I was getting the node error in the final beta, and had to go back to the previous version first, and then go to gm to get it to work. I think they fixed that in the final release.

    in reply to: Bind Lion to Active Directory with a shell script #381008
    ptrondsen
    Participant

    I got mine from Snow Leopard to work.
    It’s based on the Bombich script, I had to modify a few things.
    In order to get it to work in Snow Leopard and Lion, I had to add a few sleeps at the end.
    Good Luck

    Script:
    #! /bin/sh
    clear
    # User input
    # Check to see if root
    amiroot=`whoami`
    if [ $amiroot != root ]; then
    echo “”
    echo “ERROR! You must sudo to root to use this script”
    echo “”
    exit 1
    fi

    unit=Begining of AD NAME
    ou=”OU=”

    ### Getting Computer Name
    g=0
    while [ “$g” -eq 0 ]
    do

    printf “\nEnter Username: ”
    read name
    echo $name
    if [ $? -eq 0 ]; then
    g=`expr $g + 1`
    else
    echo “Invalid input, please renter asset number”
    fi
    done

    ####End Computer Name

    printf “\nEnter AD account that has rights to bind computers to AD: ”
    read udn
    printf “Enter password: ”
    stty -echo
    read password
    stty echo
    # Standard parameters
    domain=”yourdomain.com” # fully qualified DNS name of Active Directory Domain
    orgname=`scutil –get ComputerName`
    computerid=${unit}${name}
    printf “%16s\t%16s\n” “$orgname” “$computerid”> /tmp/”$unit.txt”
    #exit
    scutil –set HostName $computerid
    scutil –set ComputerName $computerid
    scutil –set LocalHostName $computerid
    #computerid=`echo “$up” | tr ‘a-z’ ‘A-Z’`;exit

    # Advanced options
    alldomains=”enable” # ‘enable’ or ‘disable’ automatic multi-domain authentication
    localhome=”enable” # ‘enable’ or ‘disable’ force home directory to local drive
    protocol=”smb” # ‘afp’ or ‘smb’ change how home is mounted from server
    mobile=”enable” # ‘enable’ or ‘disable’ mobile account support for offline logon
    mobileconfirm=”disable” # ‘enable’ or ‘disable’ warn the user that a mobile acct will be created
    useuncpath=”disable” # ‘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=”Your ADMIN GROUPS”,
    printf “\nComputer is being added to Active Directory with a name of “$computerid” please wait.\n ”
    ### End of configuration
    # Activate the AD plugin
    defaults write /Library/Preferences/DirectoryService/DirectoryService “Active Directory” “Active”
    plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist
    # Bind to AD
    dsconfigad -f -a $computerid -domain $domain -u $udn -p “$password” -ou “$ou”
    sleep 15

    # 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

    sleep 10
    dsconfigldap -v -a yourodserver
    sleep 15
    dscl /Search -create / SearchPolicy CSPSearchPath
    dscl /Search/Contacts -create / SearchPolicy CSPSearchPath

    sleep 30
    dscl /Search -append / CSPSearchPath “/Active Directory/All Domains”
    dscl /Search -append / CSPSearchPath /LDAPv3/yourodserver

    sleep 15
    dscl /Search/Contacts -append / CSPSearchPath “/Active Directory/All Domains”
    dscl /Search/Contacts -append / CSPSearchPath /LDAPv3/yourodserver

    # Restart DirectoryService (necessary to reload AD plugin activation settings)
    killall DirectoryService

    exit 0

Viewing 2 posts - 1 through 2 (of 2 total)