这是关于如何使用LDAP账户登录到平台的二次开发文档.
1. LDAP配置
1.1. 配置文件里配置LDAP连接属性
在项目的配置文件application.properties加入如下配置属性
lumos.web.ldap.url=ldap://119.119.119.11:389
lumos.web.ldap.username=
lumos.web.ldap.password=
lumos.web.ldap.rootdn=dc=amaxgs,dc=local
NOTE:其中username和password为LDAP的管理员用户名与密码,url为LDAP服务器的地址,rootdn为域名,可自行配置。
1.1.1. 实现接口ILdapSearchHelper中的search方法
根据ldap查询条件不同,实现search方法
@Override
public NamingEnumeration<SearchResult> search(LdapContext systemCtx, Object principal, String rootDn) {
NamingEnumeration<SearchResult> results = null;
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);//搜索范围是包括子树
try {
//sAMAccountName
results = systemCtx.search(rootDn, "sAMAccountName=" + principal , constraints);
} catch (NamingException e) {
e.printStackTrace();
}
return results;
}
NOTE:其中sAMAccountName为查询条件,查询条件可自行修改。