-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzabbix24_cuser.patch
55 lines (55 loc) · 3.59 KB
/
zabbix24_cuser.patch
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
--- /usr/share/zabbix/include/classes/api/services/CUser.php-backup-2015-06-23.php 2015-02-23 15:28:16.000000000 +0300
+++ /usr/share/zabbix/include/classes/api/services/CUser.php 2015-06-23 15:49:45.146045184 +0300
@@ -978,6 +978,52 @@
' FROM users u'.
' WHERE u.alias='.zbx_dbstr($name)
));
+
+ // No user found, try alternative authentication mechanisms.
+ if (!$userInfo) {
+ $config = select_config();
+ // Try to authenticate via the authentication type. Create an account if neccessary.
+ if ($config['authentication_type'] == ZBX_AUTH_LDAP) {
+ if ($this->ldapLogin($user)) {
+ $ldapUser = array();
+ $ldapUser['alias'] = "$name";
+ $ldapUser['name'] = "$name";
+ $ldapUser['surname'] = "$name";
+ $ldapUser['passwd'] = '';
+ $ldapUser['url'] = '';
+ $ldapUser['autologin'] = '0';
+ $ldapUser['autologout'] = '0';
+ $ldapUser['lang'] = 'ru_RU';
+ $ldapUser['theme'] = 'default';
+ $ldapUser['refresh'] = '30';
+ $ldapUser['rows_per_page'] = '250';
+ $ldapUser['type'] = '1';
+ $ldapUser['user_medias'] = array( // This is your media types array. You need one array per media type
+ array ( 'mediatypeid' => "1", // Email
+ 'sendto' => $name,
+ 'period' => "1-7,00:00-24:00;",
+ 'active' => "0", // 0 = enabled. 1 = disabled
+ 'severity' => "63", // All severity types
+ ),
+ );
+
+ $ldapUser['usrgrps'] = '15';
+
+ self::$userData['type'] = '3';
+
+ // Create the user
+ $this->create($ldapUser);
+
+ $userInfo = DBfetch(DBselect(
+ 'SELECT u.userid,u.attempt_failed,u.attempt_clock,u.attempt_ip'.
+ ' FROM users u'.
+ ' WHERE u.alias='.zbx_dbstr($name)
+ ));
+ }
+ }
+
+ }
+
if (!$userInfo) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Login name or password is incorrect.'));
}