Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
2f7531d5
Commit
2f7531d5
authored
Jan 21, 2020
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the issue that findByUserId in ldap always return the first user
parent
62b5fb30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java
...rip/framework/apollo/portal/spi/ldap/LdapUserService.java
+10
-5
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java
View file @
2f7531d5
...
...
@@ -9,10 +9,12 @@ import com.ctrip.framework.apollo.portal.spi.UserService;
import
com.ctrip.framework.apollo.portal.spi.configuration.LdapExtendProperties
;
import
com.ctrip.framework.apollo.portal.spi.configuration.LdapProperties
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Sets
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
javax.naming.Name
;
import
javax.naming.directory.Attribute
;
...
...
@@ -200,10 +202,10 @@ public class LdapUserService implements UserService {
return
ldapTemplate
.
searchForObject
(
groupBase
,
groupSearch
,
ctx
->
{
String
[]
members
=
((
DirContextAdapter
)
ctx
).
getStringAttributes
(
groupMembershipAttrName
);
List
<
UserInfo
>
userInfos
=
new
ArrayList
<>(
);
if
(!
MEMBER_UID_ATTR_NAME
.
equals
(
groupMembershipAttrName
))
{
List
<
UserInfo
>
userInfos
=
new
ArrayList
<>(
);
String
[]
members
=
((
DirContextAdapter
)
ctx
).
getStringAttributes
(
groupMembershipAttrName
);
for
(
String
item
:
members
)
{
LdapName
ldapName
=
LdapUtils
.
newLdapName
(
item
);
LdapName
memberRdn
=
LdapUtils
.
removeFirst
(
ldapName
,
LdapUtils
.
newLdapName
(
base
));
...
...
@@ -223,9 +225,12 @@ public class LdapUserService implements UserService {
}
return
userInfos
;
}
List
<
UserInfo
>
userInfos
=
new
ArrayList
<>();
String
[]
memberUids
=
((
DirContextAdapter
)
ctx
)
.
getStringAttributes
(
groupMembershipAttrName
);
Set
<
String
>
memberUids
=
Sets
.
newHashSet
(((
DirContextAdapter
)
ctx
)
.
getStringAttributes
(
groupMembershipAttrName
));
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
memberUids
=
Sets
.
intersection
(
memberUids
,
Sets
.
newHashSet
(
userIds
));
}
for
(
String
memberUid
:
memberUids
)
{
UserInfo
userInfo
=
searchUserById
(
memberUid
);
if
(
userInfo
!=
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