Advertisement
VaCaX

Prueba LDAP

Jun 24th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public static void main(String[] args) throws Exception{
  2.         LdapContextSource contextSource = new LdapContextSource();
  3.         contextSource.setUrl("ldap://IP:3268");
  4.         contextSource.setBase("DC=Borrame,DC=COM");
  5.         contextSource.setUserDn(");
  6.        contextSource.setPassword("");
  7.        contextSource.afterPropertiesSet();
  8.  
  9.        LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
  10.        ldapTemplate.afterPropertiesSet();
  11.  
  12.        // Perform the authentication.
  13.        Filter filter = new EqualsFilter("sAMAccountName", "usuario");
  14.  
  15.        boolean authed = ldapTemplate.authenticate("OU=Grupo",
  16.                filter.encode(),
  17.                "");
  18.  
  19.        // Display the results.
  20.        System.out.println("Authenticated: " + authed);
  21.  
  22.     //
  23.     //
  24.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement