菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
21
0

SPRING IN ACTION 第4版笔记-第九章Securing web applications-005-Applying LDAP-backed authentication

原创
05/13 14:22
阅读数 72214

一、

1.This method is the  LDAP analog to  jdbcAuthentication() 

1 @Override
2 protected void configure(AuthenticationManagerBuilder auth)
3 throws Exception {
4     auth
5         .ldapAuthentication()
6         .userSearchFilter("(uid={0})")
7         .groupSearchFilter("member={0}");
8 }

The userSearchFilter() and groupSearchFilter() methods are used to provide a filter for the base LDAP queries, which are used to search for users and groups. By default, the base queries for both users and groups are empty, indicating that the search will be done from the root of the LDAP hierarchy. But you can change that by specifying a query base:

 1 @Override
 2 protected void configure(AuthenticationManagerBuilder auth)
 3 throws Exception {
 4     auth
 5         .ldapAuthentication()
 6         .userSearchBase("ou=people")
 7         .userSearchFilter("(uid={0})")
 8         .groupSearchBase("ou=groups")
 9         .groupSearchFilter("member={0}");
10 }

The userSearchBase() method provides a base query for finding users. Likewise, the groupSearchBase() specifies the base query for finding groups. Rather than search from the root, this example specifies that users be searched for where the organization unit is people . And groups should be searched for where the organizational unit is groups .

发表评论

0/200
21 点赞
0 评论
收藏