• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get ldap list of users belongs to a group using java

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

If any body knows how to read list of users belongs to a group in LDAP using java. please let me know.
Currently i am getting one user belongs to a group using below code.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, principalName);
env.put(Context.SECURITY_CREDENTIALS, password);

DirContext ctx = new InitialDirContext(env);

String returnedAtts[] ={ "member" };
String searchFilter = "(&(objectClass=group)(cn=Group1))";


SearchControls searchCtls = new SearchControls();
searchCtls.setReturningAttributes(returnedAtts);

searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);


NamingEnumeration answer = ctx.search(toDC(domainName), searchFilter, searchCtls);

while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult) answer.next();
Attributes attrs = sr.getAttributes();

if (attrs != null) {
NamingEnumeration ne = attrs.getAll();

while (ne.hasMore()) {
Attribute attr = (Attribute) ne.next();
String tempSplitArr[] = attr.get().toString().split(",");
System.out.println(attr.get());
// We just need group, now we get CN=CSR UG1 for example.
String grpTemp = tempSplitArr[0];

String tempArr[] = grpTemp.split("=");
groups.add(tempArr[1]);

}
}
}
ctx.close();
Thanks in advance
 
suhasini dharmisetty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please let me know if anybody knows. I need urgent. Please help me.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the "authenticateUser" method of this source-code (StrongKey CryptoEngine - a library for encrypting files and moving them into clouds); you should be able to find hints to what you need there: http://skce.svn.sourceforge.net/viewvc/skce/skcews/src/java/com/strongauth/skcengine/SKCEImpl.java?revision=6&view=markup

Arshad Noor
StrongAuth, Inc.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi suhasini, this issue got fixed?, if it completed can you please share with me, it's very urgent
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic