第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何從 ldap 服務(wù)器讀取操作屬性

如何從 ldap 服務(wù)器讀取操作屬性

撒科打諢 2022-06-15 17:51:57
我必須從 LDAP 服務(wù)器讀取操作屬性(createTimeStamp、entryUUID 等)。我試圖實(shí)現(xiàn)自己的 UserDetailContextMapper 但沒有成功。目前我的代碼看起來像這樣Overridepublic void configure(AuthenticationManagerBuilder auth) throws Exception {    auth            .ldapAuthentication()            .userSearchFilter("uid={0}")            .groupSearchBase("ou=users")            .userDetailsContextMapper(userContextMapper())            .contextSource(contextSource());}@Beanpublic LdapContextSource contextSource() {    LdapContextSource contextSource = new LdapContextSource();    contextSource.setUrl("ldap://ldap.company.pl:389");    contextSource.setBase("dc=company,dc=com");    contextSource.afterPropertiesSet();    return contextSource;}@Beanpublic UserDetailsContextMapper userContextMapper() {    return new CustomUserDetailContextMapper();}我的 UserDetailContextMapper 實(shí)現(xiàn):public class CustomUserDetailContextMapper implements UserDetailsContextMapper {@Overridepublic UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection<?        extends GrantedAuthority> authorities) {    AutoUser user = new AutoUser();    user.setCreateTimeStamp(ctx.getStringAttribute("createTimestamp"));    user.setUUID(ctx.getStringAttribute("entryUUID"));    user.setEmail(ctx.getStringAttribute("mail"));    return user;}@Overridepublic void mapUserToContext(UserDetails user, DirContextAdapter ctx) {    //default impl}}我試過了Attributes attributes = ctx.getAttributes(username, new String[] {"*", "+"});在方法中,但如果我通過了mapUserFromContext(),我就會(huì)收到。NamingExceptionusername我正在考慮實(shí)現(xiàn) ldapTemplate.lookup(),但我不確定在哪里實(shí)現(xiàn)它,我嘗試用 ldapTemplate 做 userRepo 類,但我得到NameNotFoundException了我通過的任何 DN。
查看完整描述

1 回答

?
鴻蒙傳說

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊

  ctx.getAttributes(username, new String[] {"*", "+"});

用戶名 - 根據(jù)文檔,這應(yīng)該是 DN 這就是 LDAP 知道您從哪個(gè)記錄中提取數(shù)據(jù)的方式


第二個(gè)參數(shù),如果設(shè)置為null,它將檢索所有屬性


我相信您的錯(cuò)誤被拋出,因?yàn)槟鷤鬟f的是用戶名而不是專有名稱。


    /**

     * Retrieves selected attributes associated with a named object.

     * See {@link #getAttributes(Name, String[])} for details.

     *

     * @param name

     *          The name of the object from which to retrieve attributes

     * @param attrIds

     *          the identifiers of the attributes to retrieve.

     *          null indicates that all attributes should be retrieved;

     *          an empty array indicates that none should be retrieved.

     * @return  the requested attributes; never null

     *

     * @throws  NamingException if a naming exception is encountered

     */

    public Attributes getAttributes(String name, String[] attrIds)

            throws NamingException;


查看完整回答
反對(duì) 回復(fù) 2022-06-15
  • 1 回答
  • 0 關(guān)注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)