国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

SpringBoot整合LDAP的流程分析

發(fā)布時(shí)間:2021-07-17 21:51 來(lái)源:腳本之家 閱讀:0 作者:秋風(fēng)颯颯吹 欄目: 編程語(yǔ)言 歡迎投稿:712375056

依賴(lài)

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

配置

application.yml

spring:
  ldap:
    urls: ldap://192.168.1.53:389
    username: cn=Manager,${spring.ldap.base}
    password: hadoop
    base: dc=haohaozhu,dc=com

實(shí)體類(lèi)和Dao

/**
 * @author wen.jie
 * @date 2021/5/8 12:31
 */
@Data@ToString
@Entry(base = "ou=people,dc=haohaozhu,dc=com", objectClasses = "inetOrgPerson")
public class Person {

    @Id
    private Name id;
    @DnAttribute(value = "uid")
    private String uid;
    @Attribute(name = "cn")
    private String cn;
    @Attribute(name = "sn")
    private String sn;
    @Attribute(name="mail")
    private String mail;
    @Attribute(name = "homedirectory")
    private String homedirectory;
    @Attribute(name = "gidnumber")
    private String gidnumber;
    @Attribute(name = "uidnumber")
    private String uidnumber;

}

public interface PersonRepository extends LdapRepository<Person> {
}

測試

@SpringBootTest
class BootLdapApplicationTests {

    @Autowired
    private PersonRepository personRepository;

    @Autowired
    private LdapTemplate template;

    @Test
    public void findAll() {
        personRepository.findAll().forEach(System.out::println);
    }

    @Test
    public void findAll2() {
        Person person = template.findOne(LdapQueryBuilder.query().where("uid").is("ldapuser2"), Person.class);
        System.out.println(person);
    }

    @Test
    public void authenticationTest() {
        String uid = "ldapuser2";
        Person authenticate = template.authenticate(
                LdapQueryBuilder.query().where("uid").is(uid),
                "hadoop",
                (dirContext, ldapEntryIdentification) ->
                        template.findOne(LdapQueryBuilder.query().where("uid").is(uid), Person.class));
        System.out.println(authenticate);
    }
}

findAll:

findAll2:

authenticationTest:

到此這篇關(guān)于SpringBoot整合LDAP的流程分析的文章就介紹到這了,更多相關(guān)SpringBoot整合LDAP內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

免费A级毛片无码免费视频| 性生交片免费无码看人| 成人亚洲一区二区三区在线| JAVA性无码HD中文| 欧美国产成人精品一区二区三区| 丰满人妻被黑人中出849|