如何解决使用Spring Data Ldap时无法创建新条目
我正在尝试添加新用户,但我似乎无法使其正常工作... 这就是我映射用户实体的方式:
@Entry(base = "ou=users",objectClasses = {"inetOrgPerson","organizationalPerson","person","top","simulatedMicrosoftSecurityPrincipal"})
public class UserEntity {
@Id
@JsonIgnore
private Name id;
private String cn;
private String uid;
private String userpassword;
public UserEntity(Name id,String cn,String uid,String userpassword) {
this.id = id;
this.cn = cn;
this.uid = uid;
this.userpassword = userpassword;
}
public UserEntity() {
}
public Name getId() {
return id;
}
public void setId(Name id) {
this.id = id;
}
public String getCn() {
return cn;
}
public void setCn(String cn) {
this.cn = cn;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getUserpassword() {
return userpassword;
}
public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}
@Override
public String toString() {
return "UserEntity{" +
"id=" + id +
",cn='" + cn + '\'' +
",uid='" + uid + '\'' +
",userpassword='" + userpassword + '\'' +
'}';
}
}
我也有一个存储库:
@Repository
public interface UserRepository extends LdapRepository<UserEntity> {
}
还有一个应该存储用户的控制器:
@PostMapping("/user")
public UserEntity getUsers(@RequestBody UserEntity userEntity) throws Exception{
userEntity.setId(LdapUtils.newLdapName("ou=users"));
UserEntity save = userRepository.save(userEntity);
return save;
}
每当我尝试插入用户时,都会收到如下错误:
: ERR_277 Attribute cn not declared in objectClasses of entry ou=users,dc=wimpi,dc=net]
我不明白我在做什么错...请求是这样完成的:
{
"cn":"test2","uid":"test3","userpassword":"secret"
}
是否应该在ou = users组上创建一个新条目?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。