Skip to content

GRMrGecko/go-freeipa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

FreeIPA API client library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages