On Mon, 09 Nov 2015, Oliver Dörr wrote:
Hi,

I'm completly new to this list and the product behind it. I'm trying to use perl to get a list from my IPA installation of all users that are on the server.



#!/usr/bin/perl

use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;

my $username="admin";
my $password="secret";
my $headers= {
   'Accept' => 'application/json',
   'Content-Type' => 'application/x-www-form-urlencoded',
   'Authorization' => 'Basic',
   'user' => encode_base64($username),
   'password' => encode_base64($password)
   #encode_base64($username.":".$password)
};

my $client=REST::Client->new();
$client->setHost("https://ipa.kreditwerk.de";);
$client->POST("/ipa/session/login_password", $headers);
print Dumper $client->responseContent();

Sadly I get back
$VAR1 = '500 Not a SCALAR reference
';


I can't find any hinside the error log of the apache, even with debug enabled. I can't find any thing in the internet that helps me. (Perhaps I do not know where to look for).

So any idea where I should look at it to troubleshoot this problem?
You are doing it wrong :)

Have you read my blog article?
https://vda.li/en/posts/2015/05/28/talking-to-freeipa-api-with-sessions/

You need to:
- present referer pointing back to IPA server
- use correct accept header as 'text/plain' for session password logon
- pass username and password in the body of the request, not header,
  encoded ias form parameters 'user' and 'password'

Attached is a simple example that works.

--
/ Alexander Bokovoy

Attachment: dumpipa.pl
Description: Perl program

-- 
Manage your subscription for the Freeipa-users mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-users
Go to http://freeipa.org for more info on the project

Reply via email to