我正在尝试使用UnboundID LDAP SDK更改活动目录帐户过期设置。但我无法找到办法。任何人都可以帮我这个吗?
我需要知道如何将帐户过期延长天数,以及我们如何将其更改为从不。
谢谢,
Sasi Kumar M。
答案 0 :(得分:1)
在java中,
private static final String ACCOUNT_NEVER_EXPIRE_VALUE = "9223372036854775807";
boolean accountNeverExpire = accountExpires.equals("0") || ACCOUNT_NEVER_EXPIRE_VALUE.equals(accountExpires);
和
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);
应该让你走上正确的轨道。
-Jim
答案 1 :(得分:0)
使用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();
}