Browse Source

Implementation for anonymous bind

pull/13/head
Markus Stoll 4 years ago
parent
commit
e730579b14
  1. 13
      gitea-group-sync.go

13
gitea-group-sync.go

@ -165,11 +165,8 @@ func (c Config) checkConfig() { @@ -165,11 +165,8 @@ func (c Config) checkConfig() {
} else {
log.Printf("DialTLS:=%v:%d", c.LdapURL, c.LdapPort)
}
if len(c.LdapBindDN) == 0 {
log.Println("BIND_DN is empty")
}
if len(c.LdapBindPassword) == 0 {
log.Println("BIND_PASSWORD is empty")
if (len(c.LdapBindDN) > 0 && len(c.LdapBindPassword) == 0) {
log.Println("BIND_DN supplied, but BIND_PASSWORD is empty")
}
if len(c.LdapFilter) == 0 {
log.Println("LDAP_FILTER is empty")
@ -222,10 +219,16 @@ func mainJob() { @@ -222,10 +219,16 @@ func mainJob() {
}
defer l.Close()

if len(cfg.LdapBindDN) == 0 {
err = l.UnauthenticatedBind("")
} else {
err = l.Bind(cfg.LdapBindDN, cfg.LdapBindPassword)
}
if err != nil {
log.Fatal(err)
}

page := 1
cfg.ApiKeys.BruteforceTokenKey = 0
cfg.ApiKeys.Command = "/api/v1/admin/orgs?page=" + fmt.Sprintf("%d", page) + "&limit=20&access_token=" // List all organizations

Loading…
Cancel
Save