亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Spring Ldap 模板更新密碼?

如何使用 Spring Ldap 模板更新密碼?

三國紛爭 2023-03-23 15:05:04
我在使用 Spring LDAP 模板更改密碼時遇到問題。我不使用 Spring 安全性。我通過示例創建了應用程序,并嘗試編寫一個更改用戶密碼的新方法。我們吃:@Data@AllArgsConstructor@NoArgsConstructor@ToString(exclude = "uid")public class Person {    private String uid;    private String fullName;    private String lastName;    private String password;    public Person(String uid, String fullName, String lastName) {        super();        this.fullName = fullName;       this.lastName = lastName;    }}帶有方法的存儲庫:@Servicepublic class PersonRepository implements BaseLdapNameAware {    @Autowired    private LdapTemplate ldapTemplate;    private LdapName baseLdapPath;    public void setBaseLdapPath(LdapName baseLdapPath) {        this.baseLdapPath = baseLdapPath;    }    public Person findOne(String uid) {        Name dn = LdapNameBuilder.newInstance(baseLdapPath).add("ou", "people").add("uid", uid).build();        return ldapTemplate.lookup(dn, new PersonContextMapper());    }    public List<Person> findByName(String name) {        LdapQuery q = query().where("objectclass").is("person").and("cn").whitespaceWildcardsLike(name);        return ldapTemplate.search(q, new PersonContextMapper());    }    public void update(Person p) {        ldapTemplate.rebind(buildDn(p), null, buildAttributes(p));    }    public void updateLastName(Person p) {        Attribute attr = new BasicAttribute("sn", p.getLastName());        ModificationItem item = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);        ldapTemplate.modifyAttributes(buildDn(p), new ModificationItem[] { item });    }    public void updatePassword(Person p) {        Attribute attr = new BasicAttribute("password", p.getPassword());        ModificationItem item = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);        ldapTemplate.modifyAttributes(buildDn(p), new ModificationItem[] { item });    }    private Name buildDn(Person p) {        return LdapNameBuilder.newInstance(baseLdapPath).add("ou", "people").add("uid", p.getUid()).build();    }請幫我用這個方法。如何更新該密碼?
查看完整描述

1 回答

?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

我認為這是 userPassword 屬性



查看完整回答
反對 回復 2023-03-23
  • 1 回答
  • 0 關注
  • 203 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號