Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are looking for a full java GUI to query Active-Directory, you may have a look to <a href="http://directory.apache.org/studio/" rel="noreferrer">Apache Directory Studio</a>.</p> <p>If you want to query AD just using java, here is a sample code :</p> <pre><code>class TestAD { static DirContext ldapContext; public static void main (String[] args) throws NamingException { try { System.out.println("Début du test Active Directory"); Hashtable&lt;String, String&gt; ldapEnv = new Hashtable&lt;String, String&gt;(11); ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); //ldapEnv.put(Context.PROVIDER_URL, "ldap://societe.fr:389"); ldapEnv.put(Context.PROVIDER_URL, "ldap://dom.fr:389"); ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple"); //ldapEnv.put(Context.SECURITY_PRINCIPAL, "cn=administrateur,cn=users,dc=societe,dc=fr"); ldapEnv.put(Context.SECURITY_PRINCIPAL, "cn=jean paul blanc,ou=MonOu,dc=dom,dc=fr"); ldapEnv.put(Context.SECURITY_CREDENTIALS, "pwd"); //ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl"); //ldapEnv.put(Context.SECURITY_PROTOCOL, "simple"); ldapContext = new InitialDirContext(ldapEnv); // Create the search controls SearchControls searchCtls = new SearchControls(); //Specify the attributes to return String returnedAtts[]={"sn","givenName", "samAccountName"}; searchCtls.setReturningAttributes(returnedAtts); //Specify the search scope searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); //specify the LDAP search filter String searchFilter = "(&amp;(objectClass=user))"; //Specify the Base for the search String searchBase = "dc=dom,dc=fr"; //initialize counter to total the results int totalResults = 0; // Search for objects using the filter NamingEnumeration&lt;SearchResult&gt; answer = ldapContext.search(searchBase, searchFilter, searchCtls); //Loop through the search results while (answer.hasMoreElements()) { SearchResult sr = (SearchResult)answer.next(); totalResults++; System.out.println("&gt;&gt;&gt;" + sr.getName()); Attributes attrs = sr.getAttributes(); System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;" + attrs.get("samAccountName")); } System.out.println("Total results: " + totalResults); ldapContext.close(); } catch (Exception e) { System.out.println(" Search error: " + e); e.printStackTrace(); System.exit(-1); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload