Reputation: 865
I am trying to change the active directory account expires setting using UnboundID LDAP SDK. But i can not able to find the way to do it. Can any one please help me on this?
I need to know how to extend the Account expires by days and also how we can change it to Never.
Thanks,
Sasi Kumar M.
Upvotes: 0
Views: 348
Reputation: 865
Using UNboundID LDAP SDK
Try{
System.out.println("Going to replace account expires to never");
final Modification mod = new Modification(ModificationType.REPLACE,
"accountExpires", "9223372036854775807");
LDAPResult result=connection.modify(userDN, mod);
System.out.println("Password status : " + result);
}catch(LDAPException e) {
// TODO Auto-generated catch block
System.out.println("Error in replacing account expires to never");
e.printStackTrace();
}finally
{
System.out.println("Closing the connection.");
connection.close();
}
Upvotes: 0
Reputation: 10996
In java,
private static final String ACCOUNT_NEVER_EXPIRE_VALUE = "9223372036854775807";
boolean accountNeverExpire = accountExpires.equals("0") || ACCOUNT_NEVER_EXPIRE_VALUE.equals(accountExpires);
and
private final static long DIFF_NET_JAVA_FOR_DATES = 11644473600000L + 24 * 60 * 60 * 1000;
long adAccountExpires= Long.parseLong(accountExpires);
long milliseconds = (adAccountExpires / 10000) - DIFF_NET_JAVA_FOR_DATES;
Date accountExpiresDate= new Date(milliseconds);
Should get you on the right track.
-jim
Upvotes: 1