-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathADJoin-Centrify.sh
More file actions
129 lines (115 loc) · 3.67 KB
/
Copy pathADJoin-Centrify.sh
File metadata and controls
129 lines (115 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
##########################################
# AD Join Script - Centrify
# Josh Harvey | Jul 2017
# josh[at]macjeezy.com
# GitHub - github.com/therealmacjeezy
# JAMFnation - therealmacjeezy
##########################################
############################### Notes ##################################
# This script will bind the computer to Active Directory using the
# Centrify client.
#
# The reason for this script was due to the built in Directory Binding
# Configurations that the JSS uses for Centrify were hit or miss on
# actually binding the computer to AD. This script will take the input
# you enter in the Parameters and use them to bind the computer using
# adjoin.
#
###### Parameters ######################################################
# 4 - Domain Admin Username
# 5 - Domain Admin Password
# 6 - Encode Password (See Below - Leave blank for plain text)
# 7 - Centrify Zone (Leave blank for Auto Zone)
# 8 - Domain Being Joined
#
# If you don't want to have your actual password to be used in plain
# text, you can enter "Yes" for Parameter 6. When encoding your password
# you will have to do the following steps:
# 1. In terminal enter 'echo "passwordhere" | base64'
# 2. Copy the output and paste it into Parameter 5
# NOTE: If your password has special characters in it, be sure to
# comment them out when getting the base64 output
# (Example:'echo "p\@\$\$w0rd\!23" | base64')
#
########### ISSUES / USAGE #############################################
# If you have any issues or questions please feel free to contact
# using the information in the header of this script.
#
# Also, Please give me credit and let me know if you are going to use
# this script. I would love to know how it works out and if you find
# it helpful.
########################################################################
decodePW() {
# Decode password
adPass=`echo "$password" | base64 -D`
}
# Pull Computer Name
computerName=`scutil --get ComputerName`
# Parameter Check
# Domain Username Check
if [[ -z "$4" ]];
then
echo "Error: Domain Admin Username Missing"
errorFound=Yes
else
username="$4"
fi
# Domain Password Check
if [[ -z "$5" ]];
then
echo "Error: Domain Admin Password Missing"
errorFound=Yes
elif [[ "$6" == "Yes" ]]
then
password=`echo "$5" | base64 -D`
else
password="$5"
fi
# Encode Password Check
#if [[ -z "$6" ]];
# then
# echo "Skipping Password Decode"
#else
# decodePW
# password="$adPass"
#fi
# Centrify Zone Check
if [[ -z "$7" ]];
then
echo "Using the Auto Zone option"
useAZ=Yes
else
zone="$7"
fi
# Domain Check
if [[ -z "$8" ]];
then
echo "Error: Domain Missing"
errorFound=Yes
else
domain="$8"
fi
#//This function joins the computer to the domain using the variables previously gathered
domainJoin() {
#sudo /usr/local/sbin/adjoin -u "\"$username\"" -p "\"$password\"" -n "\"$computerName\"" -z "\"$zone\"" -f "\"$domain\""
# Uncomment line below and command line above for testing
echo "sudo /usr/local/sbin/adjoin -u "\"$username\"" -p "\"$password\"" -n "\"$computerName\"" -z "\"$zone\"" -f "\"$domain\"""
}
domainJoinAZ() {
#sudo /usr/local/sbin/adjoin -u "\"$username\"" -p "\"$password\"" -n "\"$computerName\"" -w -f "\"$domain\""
# Uncomment line below and command line above for testing
echo "sudo /usr/local/sbin/adjoin -u "\"$username\"" -p "\"$password\"" -n "\"$computerName\"" -w -f "\"$domain\"""
}
# If an error occurs while getting the parameters, it will exit with an error
if [[ "$errorFound" == "Yes" ]];
then
exit 1
fi
# Catches the option for Auto Zone join
if [[ "$useAZ" == "Yes" ]];
then
domainJoinAZ
else
domainJoin
fi