From c5085c7e6ffb62be9947a043244865aec0a203ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=80=9D=E6=95=8F?= Date: Thu, 11 Aug 2022 09:26:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=20allperson=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E7=A9=BA=E6=89=8D=E6=8F=92=E5=85=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E7=A9=BA=E6=95=B0=E6=8D=AE=E5=AF=BC=E8=87=B4=E6=B8=85?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 4c8ef72..1a4831f 100644 --- a/main.go +++ b/main.go @@ -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) })