![](/img/trans.png)
[英]How to map class attributes with underscores “_” in their names in Spring-data JPA
[英]Spring-Data LDAP missing some attributes
我有一個 Spring-Data LDAP 存儲庫,配置如下:
public interface LdapUserRepository extends LdapRepository<LdapUser> {
Set<LdapUser> findByNameLike(String name);
Optional<LdapUser> findByAccount(String account);
Optional<LdapUser> findByEmail(String email);
Optional<LdapUser> findByEmailAndPassword(String email, String password);
}
一切看起來都很好,只是有些屬性沒有被獲取。 例如,我在 LDAP 用戶上有一個employeeID
ID,並在我的 LdapUser 上映射如下:
@Attribute(name = "employeeID", readonly = true)
private String document;
當我通過(例如) Optional<LdapUser> findByAccount(String account)
查詢用戶時,除了document
字段上的employeeID
mappend 之外,幾乎所有內容都會填充。
我也可以通過非彈簧數據方式查詢它來獲取它。
好吧,兩個月后我終於找到了答案。
正如這些答案中提到的:使用 Spring LdapTemplate 從 Active Directory 獲取所有屬性, https: //stackoverflow.com/a/56839626/3120564 ,默認情況下某些屬性不會傳播到 GC。 所以我不得不將連接端口從3269
更改為389
並將@Entry
注釋上的base
屬性設置為更具體的內容(例如OU=the_OU_I_want
)。
這解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.