Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:03:51+00:00 2026-06-02T09:03:51+00:00

This is my first post, so please be gentle. I’ve recentley started using Powershell

  • 0

This is my first post, so please be gentle.

I’ve recentley started using Powershell at work to change AD groups, find AD information etc. but I’m lacking the GUI that I like so much about Java.

Is there a simple way (or example of code) whereby I enter a target hostname and I’m returned with the details I ask for. AD memberhsip groups, account info etc?

My Java knowledge isn’t as great as my Powershell so as much help as possible would be really apprechiated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:03:53+00:00Added an answer on June 2, 2026 at 9:03 am

    If you are looking for a full java GUI to query Active-Directory, you may have a look to Apache Directory Studio.

    If you want to query AD just using java, here is a sample 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<String, String> ldapEnv = new Hashtable<String, String>(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 = "(&(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<SearchResult> answer = ldapContext.search(searchBase, searchFilter, searchCtls); 
    
          //Loop through the search results 
          while (answer.hasMoreElements()) 
          { 
            SearchResult sr = (SearchResult)answer.next(); 
    
            totalResults++; 
    
            System.out.println(">>>" + sr.getName()); 
            Attributes attrs = sr.getAttributes(); 
            System.out.println(">>>>>>" + 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); 
        } 
      } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post, so please be gentle. I've been playing around with
This is my first post on this forum (so please be gentle ) I'm
This is my first post on StackOverflow, so please be gentle... I have some
This is my first post on Stack, so please bear with me if I
this is my first post on this website, Anyway, I recently started trying to
This is my first post, so please be nice :) I have a question
This is my first post, and first please forgive me for my poor english.
This is my first post, so please forgive me if this question has been
First question on SOF, please be gentle if this may be a stupid question.
This is my first post to Stack Overflow so please forgive me if I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.