Implementing Activate User

This commit is contained in:
Chris Mann 2023-07-21 09:41:30 +02:00
parent 639695d26d
commit 4dda9c91cb
2 changed files with 11 additions and 5 deletions

View file

@ -93,7 +93,7 @@ function changeDisplayname () {
displayname = document.getElementById("displayname"); displayname = document.getElementById("displayname");
username = document.getElementById("username"); username = document.getElementById("username");
givenname = document.getElementById("givenname"); givenname = document.getElementById("givenname");
sn = document.getElementById("sn"); surname = document.getElementById("surname");
if (!username.value) { if (!username.value) {
username.value = displayname.value; username.value = displayname.value;
changeUsername(); changeUsername();
@ -101,8 +101,8 @@ function changeDisplayname () {
if (!givenname.value) { if (!givenname.value) {
givenname.value = displayname.value.split(" ")[0]; givenname.value = displayname.value.split(" ")[0];
} }
if (!sn.value) { if (!surname.value) {
sn.value = displayname.value.split(" ")[1]; surname.value = displayname.value.split(" ")[1];
} }
} }
function changeUsername () { function changeUsername () {

View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"crypto/tls"
"fmt" "fmt"
"log" "log"
@ -43,7 +44,12 @@ func suggestPassword() string {
func addNewUser(newUser NewUser, config *ConfigFile) bool { func addNewUser(newUser NewUser, config *ConfigFile) bool {
log.Printf(fmt.Sprint("Adding New User")) log.Printf(fmt.Sprint("Adding New User"))
l, _ := ldap.DialURL(config.LdapServerAddr) l, _ := ldap.DialURL(config.LdapServerAddr)
err := l.StartTLS(&tls.Config{InsecureSkipVerify: true})
if err != nil {
log.Printf(fmt.Sprintf("86: %v", err))
}
l.Bind(config.NewUserDN, config.NewUserPassword) l.Bind(config.NewUserDN, config.NewUserPassword)
// l.Bind(config.) // l.Bind(config.)
dn := newUser.DN dn := newUser.DN
req := ldap.NewAddRequest(dn, nil) req := ldap.NewAddRequest(dn, nil)
@ -76,12 +82,12 @@ func addNewUser(newUser NewUser, config *ConfigFile) bool {
// conn := // conn :=
err := l.Add(req) err = l.Add(req)
log.Printf(fmt.Sprintf("71: %v", err)) log.Printf(fmt.Sprintf("71: %v", err))
log.Printf(fmt.Sprintf("72: %v", req)) log.Printf(fmt.Sprintf("72: %v", req))
log.Printf(fmt.Sprintf("73: %v", newUser)) log.Printf(fmt.Sprintf("73: %v", newUser))
if err != nil { if err != nil {
log.Printf(fmt.Sprintf("75: %v", err)) log.Printf(fmt.Sprintf("86: %v", err))
return false return false
} else { } else {
return true return true