-
Notifications
You must be signed in to change notification settings - Fork 0
/
kadduser
executable file
·49 lines (42 loc) · 1.14 KB
/
kadduser
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
#!/bin/bash
[ -e /etc/krb5.d/kutils.conf ] && source /etc/krb5.d/kutils.conf
function usage {
echo "Usage: `basename $0` -u <username> [-k <keytab>] [-R <REALM>] [-p <policy>]"
}
required=1
required_provided=0
while getopts "u:k:R:p:h" option;
do
case ${option} in
u) #Required: Service identifier
username=${OPTARG}
required_provided=$(($required_provided+1));
;;
k) #Optional: Alternative keytab file
keytab=${OPTARG}
;;
R) #Optional: Defined Realm
realm=`echo ${OPTARG} | tr a-z A-Z`
;;
p) #Optional: User defined policy
policy=${OPTARG}
;;
h)
usage;
exit 0;
;;
*)
usage;
exit 1;
esac;
done
if [ ${required_provided} -lt ${required} ]; then
usage;
exit 1;
fi;
princ=${username}
[ -n "${realm}" ] && princ="${princ}@${realm}"
${appDir}/kaddprinc -u "${princ}" -o "-policy ${policy:-${defaultUserPolicy}}"
if [ -n "${keytab}" ]; then
${appDir}/kaddkeytab -u "${princ}" -k "${keytab}"
fi;