判断 allperson是否为空才插入避免空数据导致清空
This commit is contained in:
parent
698a1241f4
commit
c5085c7e6f
10
main.go
10
main.go
|
@ -116,6 +116,7 @@ func main() {
|
||||||
pf := perfectshutdown.New()
|
pf := perfectshutdown.New()
|
||||||
|
|
||||||
pf.Loop(func(index int, cxt *perfectshutdown.PerfectShutdown) {
|
pf.Loop(func(index int, cxt *perfectshutdown.PerfectShutdown) {
|
||||||
|
|
||||||
ldapconn, err := ldap.DialURL("ldap://ldap.yuandian.com:389")
|
ldapconn, err := ldap.DialURL("ldap://ldap.yuandian.com:389")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -200,7 +201,6 @@ func main() {
|
||||||
allperson = append(allperson, dn)
|
allperson = append(allperson, dn)
|
||||||
persondict[dn] = true
|
persondict[dn] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if department.DepartID > 1 {
|
if department.DepartID > 1 {
|
||||||
|
@ -210,13 +210,15 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(string(resp.Content()))
|
log.Println(string(resp.Content()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !LdapGroupAdd(ldapconn, "源典所有成员", "源典所有成员", allperson) {
|
if len(allperson) > 0 {
|
||||||
LdapGroupModify(ldapconn, "源典所有成员", "源典所有成员", allperson)
|
if !LdapGroupAdd(ldapconn, "源典所有成员", "源典所有成员", allperson) {
|
||||||
|
LdapGroupModify(ldapconn, "源典所有成员", "源典所有成员", allperson)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cxt.Wait(time.Minute * 5)
|
cxt.Wait(time.Minute * 5)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user