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