File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Security and the fly likes read PasswordPolicyResponseValue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "read PasswordPolicyResponseValue " Watch "read PasswordPolicyResponseValue " New topic

read PasswordPolicyResponseValue

Leonardo De Stefano

Joined: Jan 31, 2002
Posts: 5
Hello. I am trying to obtain whichever days lack so that password expires.
According to I have read the way to know is obtaining a control, doing something like the following thing:
String cn = "cn=user,ou=people";
String password = "password";
LdapContext ldapCtx=null;
Properties env ;
env = new Properties();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(javax.naming.Context.PROVIDER_URL, "ldap://localhost:389" );
env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "none");
Control [] ctxCtl = new Control[] {new PasswordPolicyRequestControl()};

ldapCtx = new InitialLdapContext(env,ctxCtl);

ldapCtx.addToEnvironment(javax.naming.Context.SECURITY_AUTHENTICATION, "simple");
ldapCtx.addToEnvironment(javax.naming.Context.SECURITY_PRINCIPAL, cn);


}catch(Exception ex){
BasicControl bc = (BasicControl)ldapCtx.getResponseControls()[0];

This returns a control to me (bc), that according to the Link has the following structure.
PasswordPolicyResponseValue ::= SEQUENCE {
warning [0] CHOICE {
timeBeforeExpiration [0] INTEGER (0 .. maxInt),
graceLoginsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL
error [1] ENUMERATED {
passwordExpired (0),
accountLocked (1),
changeAfterReset (2),
passwordModNotAllowed (3),
mustSupplyOldPassword (4),
insufficientPasswordQuality (5),
passwordTooShort (6),
passwordTooYoung (7),
passwordInHistory (8) } OPTIONAL }

The problem is that i cant found the way to interpret these values in my java application.
Somebody could give an example me of like doing this.
P.D.: excuse my English
I agree. Here's the link:
subject: read PasswordPolicyResponseValue
It's not a secret anymore!