ChrisdAutume / php-freeipa

A PHP library for connect and use some features of the freeIPA / Red Hat Identity Management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-freeipa

A PHP library for connect and use some features of the freeIPA / Red Hat Identity Management

Build Status Scrutinizer Code Quality License Latest Stable Version

Quick start guide

Get CA certificate from server. Example:

# The certificate can be obtained in https://$host/ipa/config/ca.crt
wget --no-check-certificate https://ipa.demo1.freeipa.org/ipa/config/ca.crt -O certs/ipa.demo1.freeipa.org_ca.crt

Creates an instance

require_once('./bootstrap.php');
$host = 'ipa.demo1.freeipa.org';
$certificate = __DIR__ . "./certs/ipa.demo1.freeipa.org_ca.crt";
$ipa = new \FreeIPA\APIAccess\Main($host, $certificate);

Authenticates with the server

$user = 'admin';
$password = 'Secret123';
$auth = $ipa->connection()->authenticate($user, $password);
if ($auth) {
    print 'Logged in';
} else {
    $auth_info = $ipa->connection()->getAuthenticationInfo();
    var_dump($auth_info);
}

Showing the user information

$r = $ipa->user()->get($user);
var_dump($r);

Searching for users

$r = $ipa->user()->findBy('mail', 'user@company.com');
if ($r) {
    $t = count($r);
    print "Found $t users. Names: ";
    for ($i = 0; $i < $t; $i++) {
        print $r[$i]->uid[0] . ' | ';
    }
}

Insert a new user

$user_data = array(
    'givenname' => 'Richard',
    'sn' => 'Stallman',
    'uid' => "rms",
    'mail' => "rms@fsf.org",
    'userpassword' => 'Secret123',
);
$add_user = $ipa->user()->add($user_data);
if ($add_user) {
    print 'User added';
}

Insert a new group

$add_group = $ipa->group()->add("groupXYZ", "description of groupXYZ");
if ($add_group) {
    print 'Group added';
}

For more examples see file examples\all.php.

Roadmap

  • [] Implements more (all?) API methods
  • [] Implements more tests

About

A PHP library for connect and use some features of the freeIPA / Red Hat Identity Management

License:GNU Lesser General Public License v3.0


Languages

Language:PHP 100.0%