Ad Widget

Collapse

Zabbix API with LDAP authentication

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Francesco
    Member
    • Nov 2013
    • 48

    #1

    Zabbix API with LDAP authentication

    I have one problem with LDAP authentication .
    My script is:
    #!/usr/bin/perl

    use 5.010;
    use strict;
    use warnings;
    use JSON::RPC::Client;
    use Data:umper;

    # Authenticate yourself
    my $client = new JSON::RPC::Client;
    my $url = 'https://xxxxxxxx/api_jsonrpc.php';
    my $authID;
    my $response;
    my $json = {
    jsonrpc => "2.0",
    method => "user.login",
    params => {
    user => "cn=zabbixusr,cn=Users,dc=domain,dc=com" ,
    password => "xxxxxxxxxxxxx"
    },
    id => 1
    };

    $response = $client->call($url, $json);

    # Check if response was successful
    die "Authentication failed\n" unless $response->content->{'result'};

    $authID = $response->content->{'result'};
    print "Authentication successful. Auth ID: " . $authID . "\n";

    response is:
    Can't call method "content" on an undefined value at authPRD.pl line 27.

    WHYYYYYY? :-(
  • gleepwurp
    Senior Member
    • Mar 2014
    • 119

    #2
    Hi Francesco,

    I don't think you need to specify LDAP-specific format when trying to talk with the Zabbix API....

    If the "zabbixusr" account exists in your zabbix environment, just connect to it with "zabbixusr" but specify the LDAP password. That should work.


    G.

    Comment

    • Francesco
      Member
      • Nov 2013
      • 48

      #3
      everything is ok.
      The script launched on zabbixmaster works.
      The script launched on my server no. They have the same domain, but different network.

      Comment

      • dirckcopeland
        Member
        • Oct 2013
        • 50

        #4
        Zabbix API with LDAP authentication

        Just to clarify, the AD format for the user name:
        user => "cn=zabbixusr,cn=Users,dc=domain,dc=com" ,

        is not needed and this works fine when using LDAP
        user => "zabbixusr" ,

        one note of caution that bit me was make sure you use http here
        my $url = 'https://xxxxxxxx/api_jsonrpc.php';

        and not https. At least for me I got he following error when I tried to use https:

        ./auth-zabbix.pl
        Can't call method "content" on an undefined value at ./auth-zabbix.pl line 32.

        which in my script was the line:
        $authID = $response->content->{'result'};

        FYI

        Comment

        Working...