mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-20 01:52:42 +08:00
fixed: LDAP的登录部门解析需要包含上级组织作用域
This commit is contained in:
parent
b685a21717
commit
9fef487b13
@ -134,14 +134,8 @@ public class LdapUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> ouScopes = new ArrayList<>();
|
// baseDN中的ou作用域
|
||||||
String[] rdnList = baseDN.toLowerCase().split(",");
|
String ouScopesStr = baseDNOuScope(baseDN);
|
||||||
for (int i = 0; i < rdnList.length; i++) {
|
|
||||||
if (rdnList[i].startsWith("ou=")) {
|
|
||||||
ouScopes.add(rdnList[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String ouScopesStr = String.join(",", ouScopes);
|
|
||||||
|
|
||||||
List<String> units = new ArrayList<>();
|
List<String> units = new ArrayList<>();
|
||||||
while (result.hasMoreElements()) {
|
while (result.hasMoreElements()) {
|
||||||
@ -242,7 +236,12 @@ public class LdapUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ou计算
|
// ou计算
|
||||||
String[] rdnList = ldapUser.getDn().toLowerCase().split(",");
|
String baseDNOuScope = baseDNOuScope(baseDN);
|
||||||
|
String[] rdnList =
|
||||||
|
(baseDNOuScope.isEmpty()
|
||||||
|
? ldapUser.getDn().toLowerCase()
|
||||||
|
: ldapUser.getDn().toLowerCase() + "," + baseDNOuScope)
|
||||||
|
.split(",");
|
||||||
List<String> ou = new ArrayList<>();
|
List<String> ou = new ArrayList<>();
|
||||||
for (String s : rdnList) {
|
for (String s : rdnList) {
|
||||||
if (StringUtil.startsWith(s, "ou=")) {
|
if (StringUtil.startsWith(s, "ou=")) {
|
||||||
@ -271,6 +270,17 @@ public class LdapUtil {
|
|||||||
return ldapUser;
|
return ldapUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String baseDNOuScope(String baseDN) {
|
||||||
|
List<String> ouScopes = new ArrayList<>();
|
||||||
|
String[] rdnList = baseDN.toLowerCase().split(",");
|
||||||
|
for (String s : rdnList) {
|
||||||
|
if (s.startsWith("ou=")) {
|
||||||
|
ouScopes.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.join(",", ouScopes);
|
||||||
|
}
|
||||||
|
|
||||||
public static void closeContext(LdapContext ldapCtx) {
|
public static void closeContext(LdapContext ldapCtx) {
|
||||||
if (ldapCtx == null) {
|
if (ldapCtx == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user