Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loginservice
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanmw
loginservice
Commits
898acaef
Commit
898acaef
authored
May 28, 2026
by
zsluo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接ldap
parent
2311025b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
30 deletions
+15
-30
ADServiceImpl.java
...in/java/com/keymobile/sso/service/impl/ADServiceImpl.java
+15
-30
No files found.
src/main/java/com/keymobile/sso/service/impl/ADServiceImpl.java
View file @
898acaef
...
...
@@ -81,56 +81,41 @@ public class ADServiceImpl implements ADService {
return
null
;
}
// 拆分节点列表
List
<
String
>
nodeList
=
Arrays
.
stream
(
ldapInfo
.
getHost
().
split
(
","
))
.
map
(
String:
:
trim
)
.
filter
(
StringUtils:
:
isNotEmpty
)
.
toList
();
if
(
nodeList
.
isEmpty
())
{
logger
.
error
(
"LDAP主机配置为空"
);
return
null
;
}
// 全局默认端口
String
[]
nodes
=
ldapInfo
.
getHost
().
split
(
","
);
String
globalPort
=
ldapInfo
.
getPort
();
String
dn
=
ldapInfo
.
getDn
();
for
(
String
node
:
node
List
)
{
String
host
;
String
port
;
for
(
String
node
:
node
s
)
{
String
host
=
node
.
trim
()
;
String
port
=
globalPort
;
// 解析 节点自带端口 或 使用全局端口
if
(
node
.
contains
(
":"
))
{
String
[]
hp
=
node
.
split
(
":"
,
2
);
if
(
host
.
contains
(
":"
))
{
String
[]
hp
=
host
.
split
(
":"
,
2
);
host
=
hp
[
0
].
trim
();
port
=
hp
[
1
].
trim
();
}
else
{
host
=
node
;
port
=
globalPort
;
}
Hashtable
<
String
,
String
>
env
=
new
Hashtable
<>();
String
ldapUrl
=
"ldap://"
+
host
+
":"
+
port
;
Hashtable
<
String
,
String
>
env
=
new
Hashtable
<>();
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
env
.
put
(
Context
.
PROVIDER_URL
,
ldapUrl
);
env
.
put
(
Context
.
SECURITY_PRINCIPAL
,
bindUser
);
env
.
put
(
Context
.
SECURITY_CREDENTIALS
,
bindPwd
);
env
.
put
(
"com.sun.jndi.ldap.connect.timeout"
,
DEFAULT_TIME_OUT
);
env
.
put
(
"com.sun.jndi.ldap.connect.timeout"
,
"5000"
);
env
.
put
(
"com.sun.jndi.ldap.connect.timeout.net"
,
"5000"
);
env
.
put
(
"com.sun.jndi.ldap.read.timeout"
,
"5000"
);
try
{
logger
.
info
(
"
尝试连接AD域节点:{} -> 账号:{}"
,
ldapUrl
,
bindUser
);
LdapContext
ctx
=
new
InitialLdapContext
(
env
,
null
);
logger
.
info
(
"
AD域节点连接成功:{}
"
,
ldapUrl
);
logger
.
info
(
"
正在尝试连接AD节点: {}"
,
ldapUrl
);
Initial
LdapContext
ctx
=
new
InitialLdapContext
(
env
,
null
);
logger
.
info
(
"
节点 {} 连接验证成功!
"
,
ldapUrl
);
return
ctx
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"
AD域节点连接失败:{},原因:
{}"
,
ldapUrl
,
e
.
getMessage
());
logger
.
error
(
"
节点 {} 无法接通,准备自动切流。原因:
{}"
,
ldapUrl
,
e
.
getMessage
());
}
}
logger
.
error
(
"所有AD域节点全部连接失败"
);
logger
.
error
(
"致命错误:所有配置的AD域控节点全盘失联!"
);
return
null
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment