Die Katharina ist neugierig, meint sie doch, Webseiten gehen nur mit HTML … hat noch nie was von einem CMS oder einem Blogsystem gehört 😉

How to get a DirContext for an Active Directory server

How to get an initial context for an active directory…

[cc lang=”java”]
private DirContext getInitialContext() throws NamingException {

Hashtable<String, String> env = new Hashtable<String, String>(11);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, System.getProperty("ads.userdn")); //User
env.put(Context.SECURITY_CREDENTIALS, System.getProperty("ads.password")); //Password
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, System.getProperty("ads.server") + System.getProperty("ads.root"));
return new InitialDirContext(env);

}
[/cc]