refactoring changes from sequpgrade (endReturn, ...) and some modernizations
This commit is contained in:
30
seqs/ldap.sh
30
seqs/ldap.sh
@@ -12,7 +12,7 @@ seq_config() {
|
||||
# End if no configuration file exists
|
||||
dry || return 1
|
||||
fi
|
||||
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
interactive || sq_aptOpt="-y"
|
||||
|
||||
@@ -98,11 +98,11 @@ objectClass: organizationalUnit
|
||||
step_8_info() { echo "Setup SSL secured ldaps:// access"; }
|
||||
step_8() {
|
||||
sudo -u $toolUser test -r "$LDAP_CERT_KEY" >>/dev/null 2>&1
|
||||
endReturn -o $? "$toolUser cannot access certificate key file: $LDAP_CERT_KEY"
|
||||
endReturn "$toolUser cannot access certificate key file: $LDAP_CERT_KEY"
|
||||
sudo -u $toolUser test -r "$LDAP_CERT" >>/dev/null 2>&1
|
||||
endReturn -o $? "$toolUser cannot access certificate file: $LDAP_CERT"
|
||||
endReturn "$toolUser cannot access certificate file: $LDAP_CERT"
|
||||
sudo -u $toolUser test -r "$LDAP_CERT_CA" >>/dev/null 2>&1
|
||||
endReturn -o $? "$toolUser cannot access CA certificate file: $LDAP_CERT_CA"
|
||||
endReturn "$toolUser cannot access CA certificate file: $LDAP_CERT_CA"
|
||||
|
||||
local tempLdif=`eval "echo \"$sslSetup\""`
|
||||
exep "echo \"$tempLdif\" | ldapmodify -Y EXTERNAL -H ldapi:///"
|
||||
@@ -208,10 +208,10 @@ step_102() {
|
||||
fi
|
||||
|
||||
variable2Ldif add "$addUser"
|
||||
endReturn -o $? "Adding user failed"
|
||||
endReturn "Adding user failed"
|
||||
}
|
||||
userId=
|
||||
addUser="dn: uid=\$userId,\$LDAP_OU_USERS,\$LDAP_DC
|
||||
addUser="dn: uid=\$userId,\$LDAP_OU_USERS,\$LDAP_DC
|
||||
cn: \$userCn
|
||||
givenName: \$givenName
|
||||
sn: \$userSn
|
||||
@@ -235,10 +235,10 @@ step_103_alias() { echo "passwd"; }
|
||||
step_103() {
|
||||
shift
|
||||
if [ -n "${1:-}" ] ; then
|
||||
echo " [I] Password operation for $1"
|
||||
info "Password operation for $1"
|
||||
userId="$1"
|
||||
elif [ ! -z $userId ] ; then
|
||||
echo " [I] Password operation for $userId"
|
||||
info "Password operation for $userId"
|
||||
else
|
||||
error -e "No user id provided"
|
||||
return 1
|
||||
@@ -253,9 +253,9 @@ step_105() {
|
||||
shift
|
||||
if [ -n "${1:-}" ] ; then
|
||||
userId="$1"
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
elif [ ! -z $userId ] ; then
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
else
|
||||
error -e "No user id provided"
|
||||
return 1
|
||||
@@ -268,7 +268,7 @@ step_105() {
|
||||
|
||||
variable2Ldif modify "$removeFromgroup"
|
||||
variable2Ldif modify "$add2group"
|
||||
endReturn -o $? "Adding user to group failed"
|
||||
endReturn "Adding user to group failed"
|
||||
}
|
||||
#remove empty member
|
||||
add2group="dn: cn=\$groupName,\$LDAP_OU_GROUPS,\$LDAP_DC
|
||||
@@ -289,9 +289,9 @@ step_107() {
|
||||
shift
|
||||
if [ -n "${1:-}" ] ; then
|
||||
userId="$1"
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
elif [ ! -z $userId ] ; then
|
||||
echo " [I] User operation for $userId"
|
||||
info "User operation for $userId"
|
||||
else
|
||||
error -e "No user id provided"
|
||||
return 1
|
||||
@@ -354,7 +354,7 @@ step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
|
||||
step_200_alias() { echo "listgroups"; }
|
||||
step_200() {
|
||||
shift
|
||||
echo " [I] Available groups:"
|
||||
info "Available groups:"
|
||||
exe ldapsearch -x -LLL -H ldap:/// -b ${LDAP_OU_GROUPS},${LDAP_DC} dn gidNumber $*
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
|
||||
step_202_alias() { echo "listusers"; }
|
||||
step_202() {
|
||||
shift
|
||||
echo " [I] Available user:"
|
||||
info "Available user:"
|
||||
exe ldapsearch -x -LLL -H ldap:/// -b ${LDAP_OU_USERS},${LDAP_DC} dn uidNumber gidNumber $*
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user