Create one or more Active Directory Groups and add Members. Empty Groups are allowed (then all members in Zabbix will be removed from Group and disabled).
I suggest Groups for
- Zabbix Super Admin
- Zabbix Admin
- Zabbix User
as needed. The users must be direct members, do not use nested groups.
In the examples i am using the groupname `Zabbix-Super-Admin`
### 2. Install Prerequisites on Linux
Yes, i am using pure bash to avoid any prerequisites but we need a program for accessing LDAP and some other tools. All of them should be available in the standard repositories:
**Debian/Ubuntu**
`apt install ldap-utils`
**Red Hat/CentOs/SuSe**
`yum install openldap-clients`
The other needed programs are
`curl sed dirname readlink`
which should be already installed
### 3. Create Zabbix-User for API Access
It should be a non LDAP user with **Frontend acccess**`internal` (defined by Group Membership).
The User must have the **User type**`Zabbix Super Admin` for creating new users and changing group memberships.
Also avoid special chars in username and password.
In the examples i am using the username `zabbixapiuser`
### 4. Create Zabbix Target Groups
At least 2 groups are required:
**Target Group for Users:**
This Group must have **Frontend access**`LDAP `
and should be enabled.
In the examples i am using the groupname`Zabbix-Super-Admin`
**Target Group for Disabled Users:**
The build-in Group **Disabled** can be used.
Or create a new group which is **not** enabled (remove checkox) and **Frontend access**`Disabled`
In the examples i am using the groupname`LDAP-Disabled`
### 5. Check Zabbix LDAP-Settings
Check the Settings for LDAP:
Administration => Authentication => LDAP settings
I suggest to uncheck the **Case sensitive login** checkbox. The script compares the Windows `SAMAccountnames` and the Zabbix `Alias` case insensitive.
With this settings, the user can log in with `manfred`, `Manfred`and `MaNfReD`and the sync script will find and use the existing user.
### 6. Clone the script
I installed the script on the Zabbix-Server in a separate folder.
Login to Zabbix-Server and move to the root path of the `ExternalScripts` and `AlertScriptsPath` folder,
the default path is (Debian/Ubuntu/CentOS)
cd /usr/lib/zabbix/
Clone this repository, it will create a new folder named `zabbix-ldap-sync-bash`:
Change `Zabbix-Super-Admin`to your Active Directory-Groupname and `LDAP-SuperAdmin`to the target Zabbix-Groupname.
#### ZABBIX_Disabled_User_Group
ZABBIX_Disabled_User_Group="LDAP-Disabled"
Name of the Group for Disabled Users. The Group must have the ***Enabled*** checkbox unchecked or the group will not found. Every user who is removed from the group ***ZABBIX_Groupname_for_Sync*** becomes a member of this group. The reason is that a user must always be a member of at least one group in Zabbix.
The **ZABBIX_API_URL** is path to the Zabbix webinterface. Can be `http://` or `https://`, the certificate validation will be ignored.
Depending on the Zabbix installation, `/api_jsonrpc.php` or `/zabbix/api_jsonrpc.php` must be used.
#### ZABBIX_UserType_User
ZABBIX_UserType_User=3
Type of user if new one must created.
1 = Zabbix User
2 = Zabbix Admin
3 = Zabbix Super Admin
The script will not update existing users.
#### ZABBIX_MediaTypeID
ZABBIX_MediaTypeID="1"
1 is Email at new installations. Will be used for new created users if the **mail** property is not empty (Microsoft Exchange will fill theses property automatically with the sender-address).
You can check the ID of the MediaType in the webinterface
Administration => Media types => click the name of the Media
At the end of the URL you see `mediatypeid=1` with the needed ID