【JAVA】LDAP获取用户数据

package com.unis.ousyncr.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;

import javax.naming.Name;

/**
 *
 * @author 
 */
@Data
@Entry(objectClasses = {"organizationalPerson", "person", "top"},
        base = "OU=xxx,DC=xxx,DC=xx,DC=xx")
public class UserInfo {
    
    @Id
    @JsonIgnore
    private Name distinguishedName;

    @Attribute(name = "cn")
    private String commonName;

    @Attribute(name = "sn")
    private String suerName;

    @Attribute(name = "userAccountControl")
    private String status;

    /**
     * 登陆账号 带@
     */
    @Attribute(name = "userPrincipalName")
    private String loginId;

    /**
     * 登陆账号 不带@
     */
    @Attribute(name = "SamAccountName")
    private String login;

}

 

使用ldapTemplate.findAll(UserInfo.class);

拉取全量数据

posted @ 2022-10-27 10:28  独孤无绝  阅读(151)  评论(0编辑  收藏  举报