userdirectory.test

Description

object userdirectory.test(array userDirectory)

This method allows to test user directory connection settings.

This method is only available to Super admin user type.

Parameters

(object) User directory properties.

Since userdirectory.get API does not return bind_password field, userdirectoryid and/or bind_password should be supplied.
Additionally to the standard user directory properties, the method accepts the following parameters.

ParameterTypeDescription
test_usernamestringUsername to test in user directory.
test_passwordstringUsername associated password to test in user directory.

Return values

(bool) Returns true on success.

Examples

Test user directory

Test user directory for user “user1”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "userdirectory.test",
  4. "params": {
  5. "userdirectoryid": "2",
  6. "host": "127.0.0.1",
  7. "port": "3389",
  8. "base_dn": "ou=Users,dc=example,dc=org",
  9. "search_attribute": "uid",
  10. "bind_dn": "cn=ldap_search,dc=example,dc=org",
  11. "bind_password": "password",
  12. "test_username": "user1",
  13. "test_password": "password"
  14. },
  15. "auth": "3a57200802b24cda67c4e4010b50c065",
  16. "id": 1
  17. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": true,
  4. "id": 1
  5. }

Test user directory

Test non existing user “user2”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "userdirectory.test",
  4. "params": {
  5. "userdirectoryid": "2",
  6. "host": "127.0.0.1",
  7. "port": "3389",
  8. "base_dn": "ou=Users,dc=example,dc=org",
  9. "search_attribute": "uid",
  10. "bind_dn": "cn=ldap_search,dc=example,dc=org",
  11. "test_username": "user2",
  12. "test_password": "password"
  13. },
  14. "auth": "3a57200802b24cda67c4e4010b50c065",
  15. "id": 1
  16. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "error": {
  4. "code": -32500,
  5. "message": "Application error.",
  6. "data": "Incorrect user name or password or account is temporarily blocked."
  7. },
  8. "id": 1
  9. }
Test user directory for user provisioning

Test userdirectory “3” for what configured data matches the user directory settings for “user3” provisioning (e.g., what user role, user groups, user medias will be assigned to the user).

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "userdirectory.test",
  4. "params": {
  5. "userdirectoryid": "2",
  6. "host": "host.example.com",
  7. "port": "389",
  8. "base_dn": "DC=zbx,DC=local",
  9. "search_attribute": "sAMAccountName",
  10. "bind_dn": "CN=Admin,OU=Users,OU=Zabbix,DC=zbx,DC=local",
  11. "test_username": "user3",
  12. "test_password": "password"
  13. },
  14. "id": 1
  15. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "username": "user3",
  5. "name": "John",
  6. "surname": "Doe",
  7. "medias": [],
  8. "usrgrps": [
  9. {
  10. "usrgrpid": "8"
  11. },
  12. {
  13. "usrgrpid": "7"
  14. }
  15. ],
  16. "roleid": "2",
  17. "userdirectoryid": "2"
  18. },
  19. "id": 1
  20. }

Source

CUserDirectory::test() in ui/include/classes/api/services/CUserDirectory.php.