判断 allperson是否为空才插入避免空数据导致清空

This commit is contained in:
黄思敏 2022-08-11 09:26:56 +08:00
parent 698a1241f4
commit c5085c7e6f

10
main.go
View File

@ -116,6 +116,7 @@ func main() {
pf := perfectshutdown.New()
pf.Loop(func(index int, cxt *perfectshutdown.PerfectShutdown) {
ldapconn, err := ldap.DialURL("ldap://ldap.yuandian.com:389")
if err != nil {
log.Fatal(err)
@ -200,7 +201,6 @@ func main() {
allperson = append(allperson, dn)
persondict[dn] = true
}
}
if department.DepartID > 1 {
@ -210,13 +210,15 @@ func main() {
}
}
}
log.Println(string(resp.Content()))
}
if !LdapGroupAdd(ldapconn, "源典所有成员", "源典所有成员", allperson) {
LdapGroupModify(ldapconn, "源典所有成员", "源典所有成员", allperson)
if len(allperson) > 0 {
if !LdapGroupAdd(ldapconn, "源典所有成员", "源典所有成员", allperson) {
LdapGroupModify(ldapconn, "源典所有成员", "源典所有成员", allperson)
}
}
cxt.Wait(time.Minute * 5)
})