FreeIPA API client library
Go to file
2024-03-08 14:23:23 -06:00
test Initial commit 2023-08-11 09:39:38 -05:00
client_test.go Add referer to password login 2024-03-08 14:23:23 -06:00
client.go Add referer to password login 2024-03-08 14:23:23 -06:00
errors.go Add dictionary functions, cleanup documentation, and move sub element processing functions to inernal functions. 2023-08-13 19:37:01 -05:00
go.mod Initial commit 2023-08-11 09:39:38 -05:00
go.sum Initial commit 2023-08-11 09:39:38 -05:00
License.txt Initial commit 2023-08-11 09:39:38 -05:00
README.md Example code update 2023-08-13 19:39:34 -05:00
request.go Add dictionary functions, cleanup documentation, and move sub element processing functions to inernal functions. 2023-08-13 19:37:01 -05:00
response.go Add dictionary functions, cleanup documentation, and move sub element processing functions to inernal functions. 2023-08-13 19:37:01 -05:00

go-freeipa

A FreeIPA API client library for GoLang.

Install

go get github.com/grmrgecko/go-freeipa

Example

import (
    "crypto/tls"
    "log"
    "net/http"
    "github.com/grmrgecko/go-freeipa"
)

func main() {
    // Setup TLS configurations.
    tlsConifg := tls.Config{InsecureSkipVerify: false}
    transportConfig := &http.Transport{
        TLSClientConfig: &tlsConifg,
    }
    // Connect/login to FreeIPA server.
    client, err := freeipa.Connect("ipa.example.com", transportConfig, "username", "password")
    if err!=nil {
        log.Fatalln(err)
    }

    // Make a user.
    params := make(map[string]interface{})
    params["pkey_only"] = true
    params["sizelimit"] = 0
    req := freeipa.NewRequest(
        "user_find",
        []interface{}{""},
        params,
    )

    // Send the request to the test server.
    resp, err := client.Do(req)
    if err != nil {
        log.Fatalln(err)
    }

    // Print information about response.
    log.Println("Found users:", resp.Result.Count)

    dn, ok := resp.GetStringAtIndex(0, "dn")
    if !ok {
        log.Fatalln("Unable to get dn value from FreeIPA")
    }

    log.Println("Got first user DN:", dn)
}

References

If you're looking for help on what API methods there are and the arguments they accept, the documentation at FreeIPA should help:

https://github.com/freeipa/freeipa/tree/master/doc/api