mirror of https://github.com/mindoc-org/mindoc.git
parent
e7f8702c91
commit
3b4ac00943
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue