瀏覽代碼

完善ldap协议

zhangjq 5 年之前
父節點
當前提交
4619aa798a
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      engine/auth/ldap_auth.go

+ 3 - 3
engine/auth/ldap_auth.go

@@ -56,7 +56,7 @@ func (h ldapHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (ldap.LDAP
 		if bindSimplePw == "qianqiuiot.com" {
 			return ldap.LDAPResultSuccess, nil
 		}else {
-			return ldap.LDAPResultCompareFalse, nil
+			return ldap.LDAPResultInvalidCredentials, nil
 		}
 	}
 	userName := bindDN[3:]
@@ -69,7 +69,7 @@ func (h ldapHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (ldap.LDAP
 		//密码错误
 		if !strings.EqualFold(user.Password, md5Pwd) {
 			fmt.Println("密码错误")
-			return ldap.LDAPResultCompareFalse, nil
+			return ldap.LDAPResultInvalidCredentials, nil
 		}else {
 			fmt.Println("密码正确")
 			return ldap.LDAPResultSuccess, nil
@@ -97,7 +97,7 @@ func (h ldapHandler) Search(boundDN string, searchReq ldap.SearchRequest, conn n
 				userName = searchReq.BaseDN[3:]
 			}
 		}
-	}else {
+	}else if len(boundDN) > 3{
 		userName = boundDN[3:]
 	}
 	if userName != "" {