Fix LDAP server bugs

This commit is contained in:
Yang Luo
2023-05-06 23:31:46 +08:00
parent eb39e9e044
commit 9201992140
2 changed files with 12 additions and 3 deletions

View File

@ -57,11 +57,18 @@ func getNameAndOrgFromFilter(baseDN, filter string) (string, string, int) {
func getUsername(filter string) string {
nameIndex := strings.Index(filter, "cn=")
if nameIndex == -1 {
return "*"
nameIndex = strings.Index(filter, "uid=")
if nameIndex == -1 {
return "*"
} else {
nameIndex += 4
}
} else {
nameIndex += 3
}
var name string
for i := nameIndex + 3; filter[i] != ')'; i++ {
for i := nameIndex; filter[i] != ')'; i++ {
name = name + string(filter[i])
}
return name
@ -125,6 +132,8 @@ func getAttribute(attributeName string, user *object.User) message.AttributeValu
return message.AttributeValue(user.Name)
case "email":
return message.AttributeValue(user.Email)
case "mail":
return message.AttributeValue(user.Email)
case "mobile":
return message.AttributeValue(user.Phone)
case "userPassword":