feat(LDAP): LDAP设置中添加对phone字段的属性映射
This commit is contained in:
parent
560a22a186
commit
cdc790e90d
|
@ -54,11 +54,17 @@ public class LdapController {
|
|||
|
||||
// 新建用户 获取LDAP映射属性
|
||||
String name = ldapService.getMappingAttr("name", dirContext);
|
||||
String phone = ldapService.getNotRequiredMappingAttr("phone", dirContext);
|
||||
|
||||
User user = new User();
|
||||
user.setId(userId);
|
||||
user.setName(name);
|
||||
user.setEmail(email);
|
||||
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
user.setPhone(phone);
|
||||
}
|
||||
|
||||
user.setSource(UserSource.LDAP.name());
|
||||
userService.addLdapUser(user);
|
||||
}
|
||||
|
|
|
@ -213,6 +213,18 @@ public class LdapService {
|
|||
return result;
|
||||
}
|
||||
|
||||
public String getNotRequiredMappingAttr(String attr, DirContextOperations dirContext) {
|
||||
String mapping = getLdapMapping();
|
||||
JSONObject jsonObject = JSONObject.parseObject(mapping);
|
||||
|
||||
String mapAttr = jsonObject.getString(attr);
|
||||
|
||||
if (StringUtils.isNotBlank(mapAttr)) {
|
||||
return dirContext.getStringAttribute(mapAttr);
|
||||
}
|
||||
return mapAttr;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
String open = service.getValue(ParamConstants.LDAP.OPEN.getValue());
|
||||
if (StringUtils.isBlank(open)) {
|
||||
|
|
Loading…
Reference in New Issue