From 0e253dd717f6d0810a0b494903b232ac65e4660a Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Tue, 25 Sep 2018 11:09:21 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E5=A2=9E=E5=8A=A0LDAP=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/Member.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/Member.go b/models/Member.go index af2847e1..04ed7ae5 100644 --- a/models/Member.go +++ b/models/Member.go @@ -100,11 +100,13 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) { var err error lc, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", beego.AppConfig.String("ldap_host"), beego.AppConfig.DefaultInt("ldap_port", 3268))) if err != nil { + beego.Error("绑定 LDAP 用户失败 ->",err) return m, ErrLDAPConnect } defer lc.Close() err = lc.Bind(beego.AppConfig.String("ldap_user"), beego.AppConfig.String("ldap_password")) if err != nil { + beego.Error("绑定 LDAP 用户失败 ->",err) return m, ErrLDAPFirstBind } searchRequest := ldap.NewSearchRequest( @@ -117,6 +119,7 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) { ) searchResult, err := lc.Search(searchRequest) if err != nil { + beego.Error("绑定 LDAP 用户失败 ->",err) return m, ErrLDAPSearch } if len(searchResult.Entries) != 1 { @@ -125,6 +128,7 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) { userdn := searchResult.Entries[0].DN err = lc.Bind(userdn, password) if err != nil { + beego.Error("绑定 LDAP 用户失败 ->",err) return m, ErrorMemberPasswordError } if m.Account == "" { @@ -137,7 +141,7 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) { err = m.Add() if err != nil { - logs.Error("自动注册LDAP用户错误", err) + beego.Error("自动注册LDAP用户错误", err) return m, ErrorMemberPasswordError } m.ResolveRoleName()