(1) Development and configuration scenarios
Ldapserver |
OpenLDAP |
Configure Password Storage |
MD5 |
LDAP client Test |
JNDI |
LDAP client Test |
Jldap |
(2) Practice
- Confirm the LDAP server password storage method, such as MD5, Sha, and ssha.
- Confirm the LDAP server password storage rules. For example, the MD5 password string supported by OpenLDAP must be base64-encoded.
- MD5-based LDAP server entry password storage practices.
- Flowchart
- Sample Code
/** <Br/> * modify the password of the specified DN entry <br/> * <p> <strong> note: the entry must support the userpassword attribute </strong> </P> <br/> * @ Param DN for a given DN <br/> * @ Param passwd password <br/> * @ Param type password Storage Mode {MD5, sha, etc} <br/> * @ return rtnflag {true: Successful; false: Failed} <br/> */<br/> Public Boolean modifypassword (string DN, string passwd, int type) {<br/> attributes attrs = new basicattributes (); <br/> attrs. put ("userpassword", ldapsecurityutils. getopenldapmd5 (passwd); <br/> Boolean rtnflag = false; <br/> try {<br/> This. CTX. modifyattributes (DN, dircontext. replace_attribute, attrs); <br/> rtnflag = true; <br/>}catch (namingexception e) {<br/> E. printstacktrace (); <br/>}< br/> return rtnflag; <br/>}
- Problems
- Cache problem. I used the client to modify the password of a user, but the password did not change when querying from other clients.
- You need to restart the LDAP server to see the change.
- It is normal to use JNDI directly.
- Thus, the problem lies in the jldap connection configuration management module.
- The password stored in OpenLDAP uses MD5 as an example. Its MD5 is not a common MD5 and it has its own rules, as described below:
- First, convert the plaintext to the MD5 byte group.
- Base64 processing of byte groups
- Add the prefix {MD5} to the base64 processed string}
- Similarly, should Sha and ssha perform similar operations? (Verification not yet performed)
(3) References
- Http://download.csdn.net/source/3310678
- Http://download.csdn.net/source/3305804
- Base64 principle http://baike.baidu.com/view/469071.htm
- PHP method to achieve http://www.ixpub.net/thread-2055529-1-1.html