Browse Source

完善ldap协议

zhangjq 5 years ago
parent
commit
4619aa798a
1 changed files with 3 additions and 3 deletions
  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" {
 		if bindSimplePw == "qianqiuiot.com" {
 			return ldap.LDAPResultSuccess, nil
 			return ldap.LDAPResultSuccess, nil
 		}else {
 		}else {
-			return ldap.LDAPResultCompareFalse, nil
+			return ldap.LDAPResultInvalidCredentials, nil
 		}
 		}
 	}
 	}
 	userName := bindDN[3:]
 	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) {
 		if !strings.EqualFold(user.Password, md5Pwd) {
 			fmt.Println("密码错误")
 			fmt.Println("密码错误")
-			return ldap.LDAPResultCompareFalse, nil
+			return ldap.LDAPResultInvalidCredentials, nil
 		}else {
 		}else {
 			fmt.Println("密码正确")
 			fmt.Println("密码正确")
 			return ldap.LDAPResultSuccess, nil
 			return ldap.LDAPResultSuccess, nil
@@ -97,7 +97,7 @@ func (h ldapHandler) Search(boundDN string, searchReq ldap.SearchRequest, conn n
 				userName = searchReq.BaseDN[3:]
 				userName = searchReq.BaseDN[3:]
 			}
 			}
 		}
 		}
-	}else {
+	}else if len(boundDN) > 3{
 		userName = boundDN[3:]
 		userName = boundDN[3:]
 	}
 	}
 	if userName != "" {
 	if userName != "" {