用Java更改AD用户过期密码

我正在使用JNDI来更改LDAP用户的密码。 在大多数情况下(当用户的密码未过期时)此代码可以正常工作:

public InitialLdapContext connect(String url, String securityPrincipal, String password) throws AuthenticationException, NamingException { System.setProperty("javax.net.ssl.trustStore", truststore); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_PRINCIPAL, "EE\\" + securityPrincipal); env.put(Context.SECURITY_CREDENTIALS, password); env.put(Context.SECURITY_PROTOCOL, "ssl"); env.put("java.naming.ldap.version", "3"); env.put(Context.REFERRAL, "follow"); return new InitialLdapContext(env,null); } 

但是当密码过期的用户尝试更改密码时,我的应用会抛出:

 Exception: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 773, v1db1 ] com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3041) com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987) com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2789) com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2703) com.sun.jndi.ldap.LdapCtx.(LdapCtx.java:293) com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175) com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193) com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136) com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66) 

所以我的问题是:是否可以更改LDAP过期密码? 如果有可能,那么告诉如何。

Thanx寻求帮助!

如果您使用密码策略覆盖,则必须使用更改密码扩展请求。 它在JDK中不受支持,但我在Oracle Java JNDI论坛中发布了它的代码。

通过在广告中创建超级用户解决了该问题,该用户有权更改每个AD密码。 当AD用户密码过期时,超级用户更改其密码。