diff --git a/conf/app.conf.example b/conf/app.conf.example index bcac7335..ab127531 100644 --- a/conf/app.conf.example +++ b/conf/app.conf.example @@ -94,6 +94,8 @@ ldap_user=CN=ldap helper,OU=example.com,DC=example,DC=com ldap_password=superSecret #自动注册用户角色:0 超级管理员 /1 管理员/ 2 普通用户 ldap_user_role=2 +#ldap搜索filter规则,AD服务器: objectClass=User, openldap服务器: objectClass=posixAccount ,也可以定义为其他属性,如: title=mindoc +ldap_filter=objectClass=posixAccount diff --git a/conf/enumerate.go b/conf/enumerate.go index 770876a9..96c3a9c9 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -14,7 +14,9 @@ const CaptchaSessionName = "__captcha__" const RegexpEmail = `^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$` -const RegexpAccount = `^[a-zA-Z][a-zA-z0-9]{2,50}$` +//允许用户名中出现点号 + +const RegexpAccount = `^[a-zA-Z][a-zA-z0-9\.]{2,50}$` // PageSize 默认分页条数. const PageSize = 15 diff --git a/models/member.go b/models/member.go index f7f20a1b..e2e9496e 100644 --- a/models/member.go +++ b/models/member.go @@ -107,7 +107,8 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) { searchRequest := ldap.NewSearchRequest( beego.AppConfig.String("ldap_base"), ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, - fmt.Sprintf("(&(objectClass=User)(%s=%s))", beego.AppConfig.String("ldap_attribute"), account), + //修改objectClass通过配置文件获取值 + fmt.Sprintf("(&(%s)(%s=%s))",beego.AppConfig.String("ldap_filter"), beego.AppConfig.String("ldap_attribute"), account), []string{"dn", "mail"}, nil, )