1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
public class ClientLDAP {
private DirContext ctx;
public void connection (String url, String authentication, String principal, String credentials) throws ch.ldap.ClientLDAPException {
Hashtable<String,String> env;
env = new Hashtable<String,String>();
env.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put (Context.PROVIDER_URL, url);
env.put (Context.SECURITY_AUTHENTICATION, authentication);
env.put (Context.SECURITY_PRINCIPAL, principal);
env.put (Context.SECURITY_CREDENTIALS, credentials);
try {
ctx = new InitialDirContext(env);
} catch ( javax.naming.NamingException e ) {
throw new ch.ldap.ClientLDAPException("Error : Initialisation du context LDAP! (connection)", e );
}
} |