guichet/utils.go

31 lines
603 B
Go
Raw Normal View History

2023-07-20 09:20:46 +00:00
package main
import (
"fmt"
"log"
2023-07-20 09:56:11 +00:00
2023-07-20 18:02:54 +00:00
"math/rand"
2023-07-21 04:23:03 +00:00
"github.com/go-ldap/ldap/v3"
// "golang.org/x/text/encoding/unicode"
2023-07-20 09:20:46 +00:00
)
2023-07-20 09:56:11 +00:00
func openLdap(config ConfigFile) *ldap.Conn {
l, err := ldap.DialURL(config.LdapServerAddr)
if err != nil {
log.Printf(fmt.Sprint("Erreur connect LDAP %v", err))
return nil
} else {
return l
}
2023-07-20 09:20:46 +00:00
}
2023-07-20 17:55:00 +00:00
func suggestPassword() string {
2023-07-20 18:02:54 +00:00
password := ""
chars := "abcdfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*+_-="
for i := 0; i < 12; i++ {
password += string([]rune(chars)[rand.Intn(len(chars))])
2023-07-20 17:55:00 +00:00
}
2023-07-20 18:02:54 +00:00
return password
2023-07-20 15:52:16 +00:00
}