• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

read PasswordPolicyResponseValue

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ;
try{
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);
ldapCtx.addToEnvironment(javax.naming.Context.SECURITY_CREDENTIALS,password);

ldapCtx.reconnect(ctxCtl);

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

This returns a control to me (bc), that according to the Link http://mirrors.sunsite.dk/drafts/draft-behera-ldap-password-policy-07.txt 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic