API Examples for IPA
Edit me

API Examples for IPA

Auth

$ curl https://idm.example.net/ipa/session/login_password -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/plain' -X POST --data 'user=[username]&password=[password]' -c ipa_token

$ cat ipa_token
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_idm.example.net	FALSE	/ipa	TRUE	0	ipa_session	MagBearerToken=jzAxxyltmlOMHkOLsFcx%2bbH0fuFk4wcD2UvmGtgQIZcsw185ZDCiCy31ekqvXdVpAL08oDM%2fUrRATFYHZFPbgYC5Fu

Get User info with API

$ cat idm_api_test
{
    "id": 0,
    "method": "user_show",
    "params": [
        [
            "john"
        ],
        {
            "version": "2.231"
        }
    ]
}

$ curl -s -H referer:https://idm.example.net/ipa -H "Content-Type:application/json" -H "Accept:application/json"  -b ipa_token -d  "$(cat idm_api_test)" -X POST https://idm.example.net/ipa/session/json | jq .
{
  "result": {
    "result": {
      "dn": "uid=john,cn=users,cn=accounts,dc=exmple,dc=net",
      "memberof_group": [
        "ipausers"
      ],
      "uid": [
        "john"
      ],
      "krbcanonicalname": [
        "john@EXAMPLE.NET"
      ],
      "loginshell": [
        "/bin/bash"
      ],
      "uidnumber": [
        "251200029"
      ],
      "memberofindirect_sudorule": [
        "allow_all-systems_administrators"
      ],
      "gidnumber": [
        "251200029"
      ],
      "has_keytab": true,
      "has_password": true,
      "sn": [
        "John"
      ],
      "homedirectory": [
        "/home/john"
      ],
      "mail": [
        "john@example.net"
      ],
      "krbprincipalname": [
        "john@EXAMPLE.NET"
      ],
      "givenname": [
        "Jun"
      ],
      "nsaccountlock": false
    },
    "value": "john",
    "summary": null
  },
  "version": "4.6.6",
  "error": null,
  "id": 0,
  "principal": "john@EXAMPLE.NET"
}
Tags: idm