Skip to content

Commit e730579

Browse files
committed
Implementation for anonymous bind
1 parent 032c41e commit e730579

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

gitea-group-sync.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,8 @@ func (c Config) checkConfig() {
165165
} else {
166166
log.Printf("DialTLS:=%v:%d", c.LdapURL, c.LdapPort)
167167
}
168-
if len(c.LdapBindDN) == 0 {
169-
log.Println("BIND_DN is empty")
170-
}
171-
if len(c.LdapBindPassword) == 0 {
172-
log.Println("BIND_PASSWORD is empty")
168+
if (len(c.LdapBindDN) > 0 && len(c.LdapBindPassword) == 0) {
169+
log.Println("BIND_DN supplied, but BIND_PASSWORD is empty")
173170
}
174171
if len(c.LdapFilter) == 0 {
175172
log.Println("LDAP_FILTER is empty")
@@ -222,10 +219,16 @@ func mainJob() {
222219
}
223220
defer l.Close()
224221

225-
err = l.Bind(cfg.LdapBindDN, cfg.LdapBindPassword)
222+
if len(cfg.LdapBindDN) == 0 {
223+
err = l.UnauthenticatedBind("")
224+
} else {
225+
err = l.Bind(cfg.LdapBindDN, cfg.LdapBindPassword)
226+
}
227+
226228
if err != nil {
227229
log.Fatal(err)
228230
}
231+
229232
page := 1
230233
cfg.ApiKeys.BruteforceTokenKey = 0
231234
cfg.ApiKeys.Command = "/api/v1/admin/orgs?page=" + fmt.Sprintf("%d", page) + "&limit=20&access_token=" // List all organizations

0 commit comments

Comments
 (0)