springcloud使用LDAP操作AD域更新数据
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
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;
// objectClasses根据需要选择,可在ADSI编辑器中查看,不添加会报错
@Entry(objectClasses = { "organizationalPerson", "person", "top", "user" })
public class ADUser {
@Id
private Name dn;
/**
* 域账号
*/
@Attribute(name = "sAMAccountName")
private String sAMAccountName;
@Attribute(name = "cn")
private String commonName;
@Attribute(name = "sn")
private String suerName;
/**
* 过期时间
*/
@Attribute(name = "accountExpires")
private Long accountExpires;
/**
* 姓名
*/
@Attribute(name = "displayName")
private String userName;
/**
* 邮箱
*/
@Attribute(name = "mail")
private String userEmail;
/**
* 部门
*/
@Attribute(name = "department")
private String department;
/**
* 岗位
*/
@Attribute(name = "title")
private String title;
@Attribute(name = "memberOf")
private String groupListStr;
public Name getDn() {
return dn;
}
public void setDn(Name dn) {
this.dn = dn;
}
public String getsAMAccountName() {
return sAMAccountName;
}
public void setsAMAccountName(String sAMAccountName) {
this.sAMAccountName = sAMAccountName;
}
public String getCommonName() {
return commonName;
}
public void setCommonName(String commonName) {
this.commonName = commonName;
}
public String getSuerName() {
return suerName;
}
public void setSuerName(String suerName) {
this.suerName = suerName;
}
public Long getAccountExpires() {
return accountExpires;
}
public void setAccountExpires(Long accountExpires) {
this.accountExpires = accountExpires;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getGroupListStr() {
return groupListStr;
}
public void setGroupListStr(String groupListStr) {
this.groupListStr = groupListStr;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("groupListStr", getGroupListStr())
.append("commonName", getCommonName())
.append("suerName", getSuerName())
.append("sAMAccountName", getsAMAccountName())
.append("accountExpires", getAccountExpires())
.toString();
}