Added Support for Zabbix 5.2 and higher
This commit is contained in:
parent
ba4c8dd6a4
commit
3973fc78f8
31
README.md
31
README.md
@ -6,15 +6,18 @@ This is a pure bash-script for syncing a Actice-Directory Group via LDAP with a
|
||||
- 2020-04-17 V1.1a => Replace hard coded $2 with push-solution
|
||||
- 2020-05-05 V1.1b => add ldapsearch parameter `-o ldif-wrap=no` to prevent line breaks after 79 chars
|
||||
- 2020-08-06 V1.1c => add more debbuging for -v when a new user is created (show the full curl command)
|
||||
- 2021-01-10 V1.2 => add support for Zabbix 5.2 or higher (breaking changes in API) with API-Version check bultin
|
||||
<br>
|
||||
|
||||
## Features
|
||||
- Pure Bash Skript for Linux
|
||||
- LDAP and LDAPS Support (ignoring SSL possible)
|
||||
- Zabbix API via http / https (ignoring SLL per default)
|
||||
- Zabbix 3.x, 4.x and 5.0 tested (will not not work with 5.2 (work in progress)!)
|
||||
- Zabbix 3.x, 4.x and 5.x tested (new User Roles since Version 5.2 are supported)
|
||||
- Multiple config-files possible for multiple groups and multiple domains
|
||||
- Create needed users in Zabbix as User, Admin or SuperAdmin, including Email-Address as media
|
||||
- Create needed users in Zabbix including Email-Address as media
|
||||
- up to Zabbix 5.0.x as User, Admin or SuperAdmin
|
||||
- from Zabbix 5.2.x using the User Role (roleid)
|
||||
- Disable users in Zabbix which are removed from Group
|
||||
- user- or group names with spaces are no problem
|
||||
|
||||
@ -158,11 +161,18 @@ Depending on the Zabbix installation, `/api_jsonrpc.php` or `/zabbix/api_jsonrp
|
||||
|
||||
#### ZABBIX_UserType_User
|
||||
ZABBIX_UserType_User=3
|
||||
Type of user if new one must created.
|
||||
up to Zabbix 5.0.x there are 3 bultin Types, 1,2 or 3
|
||||
from Zabbix 5.2.x there are User Rules. There are 3 predefined user roles which correspond to the pevious user types.
|
||||
but you can define additional user roles in Zabbix and use here
|
||||
The bultin Types (<=5.0.x) or predefined Roles (>=5.2.x) are
|
||||
1 = Zabbix User
|
||||
2 = Zabbix Admin
|
||||
3 = Zabbix Super Admin
|
||||
The script will not update existing users.
|
||||
The script will not update existing zabbix-users.
|
||||
You can check the ID of the RoleId in the webinterface
|
||||
|
||||
Administration => User roles => click the name of the role
|
||||
At the end of the URL you see `roleid=1` with the needed ID
|
||||
|
||||
#### ZABBIX_MediaTypeID
|
||||
ZABBIX_MediaTypeID="1"
|
||||
@ -176,13 +186,15 @@ At the end of the URL you see `mediatypeid=1` with the needed ID
|
||||
You should get some output like this:
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
zabbix-ldap-sync.sh (Version V1.1 (2020-04-14)) startup
|
||||
zabbix-ldap-sync.sh (Version V1.2 (2021-01-10)) startup
|
||||
Checking prerequisites ............................................... done
|
||||
Searching config file ................................................ done
|
||||
Reading "/usr/lib/zabbix/zabbix-ldap-sync/config-znil.sh" ............ done
|
||||
Reading "/usr/lib/zabbix/zabbix-ldap-sync-bash/config-znil.sh" ....... done
|
||||
Check all needed Settings ............................................ done
|
||||
STEP 1: Getting all Members from Active Directory / LDAP Group ....... done
|
||||
Query sAMAccountName, sn, givenName and primary Email-Address ........ done
|
||||
Check Zabbix API Version ............................................. done
|
||||
Using User mode ...................................................... roleid
|
||||
Login at Zabbix API .................................................. done
|
||||
STEP 2: Get Members of Zabbix-LDAP Groups ............................ checking
|
||||
determine UsrGrpID of "LDAP-SuperAdmin" .............................. done
|
||||
@ -190,17 +202,18 @@ You should get some output like this:
|
||||
determine alias and userid for Members of "LDAP-SuperAdmin" .......... done
|
||||
STEP 3: Compare Groups for changes ................................... checking
|
||||
Check 1: Number of Users LDAP ........................................ 4
|
||||
Check 1: Number of Users Zabbix ...................................... 2
|
||||
Check 1: Number of Users Zabbix ...................................... 1
|
||||
Check 1: Number of Users ............................................. not equal
|
||||
STEP 4: Get all Zabbix Users with alias and userid ................... done
|
||||
STEP 5: Compare LDAP user with existing Zabbix User .................. must create 1 new user
|
||||
STEP 6: Create needed 1 new Zabbix-User .............................. done
|
||||
STEP 5: Compare LDAP user with existing Zabbix User .................. must create 3 new user
|
||||
STEP 6: Create needed 3 new Zabbix-User .............................. done
|
||||
STEP 7: Replace Members of Group LDAP-SuperAdmin ..................... done
|
||||
STEP 8: Get List of all disabled user in Group LDAP-Disabled ......... done
|
||||
STEP 9: Remove active user, add inactive user ........................ done
|
||||
STEP 10: Replace Members of Group LDAP-Disabled ...................... done
|
||||
STEP 11: Replace Members of Group LDAP-SuperAdmin (2. Time) .......... done
|
||||
Logout Zabbix API .................................................... done
|
||||
|
||||
If there is an error with Login to LDAP or Zabbix an Error Message will be displayed. Check Output for more.
|
||||
## Advanced Debugging
|
||||
Try
|
||||
|
@ -43,19 +43,47 @@ ZABBIX_API_URL="http://localhost/api_jsonrpc.php"
|
||||
ZABBIX_API_User="zabbixapiuser"
|
||||
ZABBIX_API_Password="strongpassword73#"
|
||||
|
||||
# Zabbix User type for new created Users:
|
||||
# 1 - (default) Zabbix user;
|
||||
# Zabbix User type (up to Zabbix Version 5.0.x) oder RoleId (from Version 5.2.x) for new created Users.
|
||||
# up to Zabbix 5.0.x there are 3 bultin Types, 1,2 or 3
|
||||
# from Zabbix 5.2.x there are User Rules. There are 3 predefined user roles which correspond to the pevious user types.
|
||||
# but you can define additional user roles in Zabbix and use here
|
||||
# 1 - Zabbix user;
|
||||
# 2 - Zabbix admin;
|
||||
# 3 - Zabbix super admin.
|
||||
ZABBIX_UserType_User=3
|
||||
|
||||
# Zabbix Media Type Id
|
||||
# At new Installation:
|
||||
# At new Installation
|
||||
# 1 - Email
|
||||
# 2 - Jabber
|
||||
# 3 - SMS
|
||||
# Media Type Id can be different if you add own Types, Delete Default Types or If have an Installation witch used "nodes" (Zabbix 2.x) in the past and you have set the bode-Id
|
||||
# 4 - Email (HTML)
|
||||
# 5 - Mattermost
|
||||
# 6 - Opsgenie
|
||||
# 7 - PagerDuty
|
||||
# 8 - Pushover
|
||||
# 9 - Slack
|
||||
# 10 - Discord
|
||||
# 11 - SIGNL4
|
||||
# 12 - Jira
|
||||
# 13 - Jira with CustomFields
|
||||
# 14 - MS Teams
|
||||
# 15 - Redmine
|
||||
# 16 - Telegram
|
||||
# 17 - Zendesk
|
||||
# 18 - ServiceNow
|
||||
# 19 - Zammad
|
||||
# 20 - Jira ServiceDesk
|
||||
# 21 - OTRS
|
||||
# 22 - iLert
|
||||
# 23 - SolarWinds Service Desk
|
||||
# 24 - SysAid
|
||||
# 25 - TOPdesk
|
||||
# 26 - iTop
|
||||
|
||||
# Media Type Id can be different if you added own Types, delete Default Types or if you have an installation witch used "nodes" (Zabbix 2.x) in the past and you have set the node-Id
|
||||
ZABBIX_MediaTypeID="1"
|
||||
|
||||
#############################################################################################################
|
||||
# ______ _ __ ______ _ _
|
||||
# | ____| | | / _| | ____(_) |
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
#############################################################################################################
|
||||
# Script Name ...: zabbix-ldap-sync.sh
|
||||
# Version .......: V1.1c
|
||||
# Date ..........: 06.08.2020
|
||||
# Version .......: V1.3
|
||||
# Date ..........: 10.01.2021
|
||||
# Description....: Synchronise Members of a Actice Directory Group with Zabbix via API
|
||||
# User wich are removed will be deactivated
|
||||
# Args ..........:
|
||||
@ -11,7 +11,7 @@
|
||||
# Email Private : Bernhard@znil.de
|
||||
#############################################################################################################
|
||||
# Variables
|
||||
Script_Version="V1.1c (2020-08-06)"
|
||||
Script_Version="V1.2 (2021-01-10)"
|
||||
# Colors for printf and echo
|
||||
DEFAULT_FOREGROUND=39
|
||||
RED=31
|
||||
@ -116,6 +116,64 @@ Translate_ldapsearch_exitcode () {
|
||||
echo " (for more details: https://ldapwiki.com/wiki/LDAP%20Result%20Codes)"
|
||||
}
|
||||
# Translate_ldapsearch_exitcode ### END Function #####################################################################
|
||||
# CompareVersionNumbers ### START Function #####################################################################
|
||||
# Source: https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
|
||||
CompareVersionNumbers () {
|
||||
if [[ $1 == $2 ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
local IFS=.
|
||||
local i ver1=($1) ver2=($2)
|
||||
# fill empty fields in ver1 with zeros
|
||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
|
||||
do
|
||||
ver1[i]=0
|
||||
done
|
||||
for ((i=0; i<${#ver1[@]}; i++))
|
||||
do
|
||||
if [[ -z ${ver2[i]} ]]
|
||||
then
|
||||
# fill empty fields in ver2 with zeros
|
||||
ver2[i]=0
|
||||
fi
|
||||
if ((10#${ver1[i]} > 10#${ver2[i]}))
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
if ((10#${ver1[i]} < 10#${ver2[i]}))
|
||||
then
|
||||
return 2
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
# VersionNumbers ### END Function #####################################################################
|
||||
# TestVersionNumbers ### START Function #####################################################################
|
||||
# Source: https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
|
||||
# TestVersionNumbers ### END Function #####################################################################
|
||||
TestVersionNumbers () {
|
||||
CompareVersionNumbers $1 $2
|
||||
case $? in
|
||||
0) op='=';;
|
||||
1) op='>';;
|
||||
2) op='<';;
|
||||
esac
|
||||
if [[ $op != $3 ]]
|
||||
then
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
echo "CompareVersionNumbers: '$1' is higher than '$2'"
|
||||
fi
|
||||
# 1 = false
|
||||
return 1
|
||||
else
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
echo "CompareVersionNumbers: '$1' is lower than '$2'"
|
||||
fi
|
||||
# 0 = true
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
# Zabbix_Logout ### START Function #####################################################################
|
||||
Zabbix_Logout () {
|
||||
Print_Status_Text "Logout Zabbix API"
|
||||
@ -133,7 +191,9 @@ Zabbix_Logout () {
|
||||
Print_Status_Done "done" $GREEN
|
||||
b_Zabbix_is_logged_in="false"
|
||||
}
|
||||
# Zabbix_Logout ### START Function ##################################################################################################################################################################################
|
||||
# Zabbix_Logout ### END Function #####################################################################
|
||||
|
||||
##################################################################################################################################################################################
|
||||
# _____ _ _
|
||||
# / ____| | | |
|
||||
# | (___ | |_ __ _ _ __| |_ _ _ _ __
|
||||
@ -183,7 +243,14 @@ done
|
||||
if [ "$b_Unknown_Parameter" = "true" ]; then
|
||||
# ToDo: Create Help text
|
||||
echo "Parameter error - print help"
|
||||
echo "In Future here will be some helping text"
|
||||
echo
|
||||
echo " Allowed Parameter are:"
|
||||
echo " -c | -C | --config use a specific configuration file instead config.sh"
|
||||
echo " -v | -V | --verbose Display debugging information, include all commands"
|
||||
echo " -p | -P | --ShowPassword Show the passwords in the verbose output"
|
||||
echo " -s | -S | --silent Hide all Output except errors. Usefull with crontab"
|
||||
echo
|
||||
echo "HowTo and Manual: https://github.com/BernhardLinz/zabbix-ldap-sync-bash"
|
||||
exit 1
|
||||
fi
|
||||
#############################################################################################################
|
||||
@ -563,6 +630,47 @@ fi
|
||||
|
||||
|
||||
|
||||
##########################################################################################################################
|
||||
# _____ _ _ ______ _ _ _ _____ _____ __ __ _
|
||||
# / ____| | | | |___ / | | | | (_) /\ | __ \_ _| \ \ / / (_)
|
||||
# | | | |__ ___ ___| | __ / / __ _| |__ | |__ ___ __ / \ | |__) || | \ \ / /__ _ __ ___ _ ___ _ __
|
||||
# | | | '_ \ / _ \/ __| |/ / / / / _` | '_ \| '_ \| \ \/ / / /\ \ | ___/ | | \ \/ / _ \ '__/ __| |/ _ \| '_ \
|
||||
# | |____| | | | __/ (__| < / /_| (_| | |_) | |_) | |> < / ____ \| | _| |_ \ / __/ | \__ \ | (_) | | | |
|
||||
# \_____|_| |_|\___|\___|_|\_\ /_____\__,_|_.__/|_.__/|_/_/\_\ /_/ \_\_| |_____| \/ \___|_| |___/_|\___/|_| |_|
|
||||
#
|
||||
##########################################################################################################################
|
||||
# There are breaking changes at the Zabbix API since Version 5.2 or higher, so we have to check the version
|
||||
Print_Status_Text "Check Zabbix API Version"
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
Print_Status_Done "checking" $LIGHTCYAN
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc": "2.0","method":"apiinfo.version","params":[],"id":42}'
|
||||
printf "'"
|
||||
echo " $ZABBIX_API_URL"
|
||||
fi
|
||||
myAPIVersion=$(curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc": "2.0","method":"apiinfo.version","params":[],"id":42}' $ZABBIX_API_URL | cut -d'"' -f8)
|
||||
if [ "$b_verbose" = "true" ]; then echo "Zabbix Server Version: $myAPIVersion"; fi
|
||||
TestVersionNumbers "$myAPIVersion" "5.0.999" "<"
|
||||
if [ "$?" = "1" ]; then
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
echo "Zabbix API Version is higher than 5.0.x - using User-RoleId-Mode"
|
||||
fi
|
||||
s_UserMode="roleid"
|
||||
else
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
echo "Zabbix API Version is 5.0.x or lower - using User-Type-Mode"
|
||||
fi
|
||||
s_UserMode="type"
|
||||
fi
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
Print_Status_Text "Check Zabbix API Version"
|
||||
fi
|
||||
Print_Status_Done "done" $GREEN
|
||||
Print_Status_Text "Using User mode"
|
||||
Print_Status_Done "$s_UserMode" $LIGHTGREEN
|
||||
|
||||
|
||||
#############################################################################################################
|
||||
# ______ _ _ _ _ _
|
||||
# |___ / | | | | (_) | | (_)
|
||||
@ -602,7 +710,6 @@ if [ "$b_verbose" = "true" ]; then
|
||||
Print_Status_Text "Login at Zabbix API"
|
||||
fi
|
||||
Print_Status_Done "done" $GREEN
|
||||
|
||||
#############################################################################################################
|
||||
# ____ ______ _ _ _ _____
|
||||
# / __ \ |___ / | | | | (_) / ____|
|
||||
@ -965,82 +1072,82 @@ if [ "$b_Must_Sync_Users" = "true" ]; then
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
"OOX") # Email, but no Surname or Givenname
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
|
||||
;;
|
||||
"OXO") # Givenname, but no Surname or Email
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
"OXX") # Givenname and Email, no Surname
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"name":'"$tempNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
"XOO") # Surname, but no Givenname or Email
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
"XOX") # Surname and Email, but no Givenname
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
"XXO") # Surname and Givenname, but no Email
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
"XXX") # Surname, Givenname and Email
|
||||
if [ "$b_verbose" = "true" ]; then
|
||||
printf 'curl -k -s -X POST -H "Content-Type:application/json" -d '
|
||||
printf "'"
|
||||
printf '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}'
|
||||
printf "'"
|
||||
echo $ZABBIX_API_URL
|
||||
fi
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"type":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
tempvar=`curl -k -s -X POST -H "Content-Type:application/json" -d '{"jsonrpc": "2.0","method":"user.create","params":{"alias":'"$tempSAM"',"name":'"$tempNAME"',"surname":'"$tempSURNAME"',"user_medias":[{"mediatypeid": "'$ZABBIX_MediaTypeID'","sendto":['"$tempEmail"']}],"usrgrps":[{"usrgrpid":"'$ZABBIX_LDAP_Group_UsrGrpId'"}],"'$s_UserMode'":'$ZABBIX_UserType_User'},"id":42,"auth":"'$ZABBIX_authentication_token'"}' $ZABBIX_API_URL`
|
||||
;;
|
||||
esac
|
||||
if [ "$b_verbose" = "true" ]; then echo "$tempvar"; fi
|
||||
|
Loading…
Reference in New Issue
Block a user