Posted By:
Kasper_Dueholm
Posted On:
Monday, August 14, 2006 08:29 AM
Is there a way to retrieve the maxPwdAge value from the group policy? I use JNDI to look up users in MS Active Directory (LDAP). This works fine - but I also want to know the maximum password age for the user which is to be found in the policy. I have seen different articles about domainDNS but nothing really useful. Here is some of the code that I wrote so far - it doesn't work : **************************************** Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://ad_server:389/DC=company,DC=com"); e
More>>
Is there a way to retrieve the maxPwdAge value from the group policy?
I use JNDI to look up users in MS Active Directory (LDAP). This works fine - but I also want to know the maximum password age for the user which is to be found in the policy.
I have seen different articles about
domainDNS
but nothing really useful.
Here is some of the code that I wrote so far -
it doesn't work
:
****************************************
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://ad_server:389/DC=company,DC=com");
env.put(Context.SECURITY_PRINCIPAL, "CN=admin,OU=orgunit,DC=company,DC=com");
env.put(Context.SECURITY_CREDENTIALS, "adminpwd");
try {
// Create the initial directory context
DirContext ctx = new InitialDirContext(env);
// Ask for all attributes of the object
Attributes attrs = ctx.getAttributes("cn=some_name, ou=orgunit");
// Find the maximum password age ("maxPwdAge") and print it
out.println("maximum pwd age: " + attrs.get("maxPwdAge").get());
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
out.println("Problem getting attribute: " + e);
}
}
****************************************
By the way - I code JSP! Not that I should matter (?)...
Can someone please help me...? Thanks!
/Kasper
<<Less