Skip to content

Instantly share code, notes, and snippets.

@raphink
Created December 3, 2019 15:17
Show Gist options
  • Save raphink/2db490006cb0483948da4f5ee025a49a to your computer and use it in GitHub Desktop.
Save raphink/2db490006cb0483948da4f5ee025a49a to your computer and use it in GitHub Desktop.
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"github.com/tehwalris/go-freeipa/freeipa"
)
func main() {
host := "ipa.example.test"
username := "admin"
password := "123456789"
truuue := true
hostname := "toto.example.test"
tspt := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
c, e := freeipa.Connect(host, tspt, username, password)
if e != nil {
log.Fatal(e)
}
res, e := c.HostShow(
&freeipa.HostShowArgs{
Fqdn: hostname,
},
&freeipa.HostShowOptionalArgs{},
)
if e != nil {
if res != nil {
log.Fatal(e)
} else {
resa, e := c.HostAdd(
&freeipa.HostAddArgs{
Fqdn: "toto.example.test",
},
&freeipa.HostAddOptionalArgs{
Force: &truuue,
Random: &truuue,
},
)
if e != nil {
log.Fatal(e)
}
fmt.Println(resa)
passwd := resa.Result.Randompassword
fmt.Println(*passwd)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment