• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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
 
Hang a left on main. Then read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic