• Post Reply Bookmark Topic Watch Topic
  • New Topic

LDAP Dynamic Groups  RSS feed

 
nagesh uppuluri
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have been trying to do some coding around - fetching members of dynamic ldap groups. In both these code snippets.. When casting
com.sun.jndi.ldap.obj.GroupOfURLs gurls = (com.sun.jndi.ldap.obj.GroupOfURLs) searchedObject;
or
java.security.acl.Group obj = (java.security.acl.Group)ctx.lookup(groupDN);
I get the same exception:
java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx
no matter whatever i tried. Can anyone please - let me know what could be causing this exception.

Regards.


String filter = LDAPRealm.DYNAMIC_GROUP_FILTER;

String[] targets = new String[] { target, "memberUrl" };

try {
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(targets);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
ctls.setReturningObjFlag(true);

NamingEnumeration e = context.search(baseDN, filter, ctls);

while(e.hasMore()) {
SearchResult res = (SearchResult)e.next();
Object searchedObject = res.getObject();
//if(searchedObject instanceof com.sun.jndi.ldap.obj.GroupOfURLs){ // dynamic group
com.sun.jndi.ldap.obj.GroupOfURLs gurls = (com.sun.jndi.ldap.obj.GroupOfURLs) searchedObject;
Principal x500principal = new X500Principal(userDN);
if (gurls.isMember(x500principal)) {


and


java.security.acl.Group obj = (java.security.acl.Group)ctx.lookup(groupDN);
Enumeration members = obj.members();
Principal member = null;
while (members.hasMoreElements()) {
member = (Principal)members.nextElement();
memberDNs.add(member.getName());
}

Please provide any code pointers if there is a dynamic groups member listing code available.
Regards.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!