簡體   English   中英

如何使用Spring和Java從LDAP獲取userPassword屬性

[英]How get userPassword attribute from LDAP using Spring and Java

我想在Java中使用Spring從ldap獲取userPassword屬性。

當然這不起作用:

context.getStringAttribute("userPassword");

如果我嘗試:

context.getObjectAttribute("userPassword");

我可以獲取此屬性..但是現在如何從Object獲取哈希密碼?

聽起來像context.getObjectAttribute("userPassword")返回一個Object所以您只需要確定它是什么即可。

根據注釋,它是一個byte[]數組,表示一個String ,因此您基本上可以這樣做:

Object o = context.getObjectAttribute("userPassword");
byte[] bytes = (byte[]) o;
String hash = new String(bytes);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM