aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JNDI Active Directory Search issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI Active Directory Search issue" Watch "JNDI Active Directory Search issue" New topic
Author

JNDI Active Directory Search issue

purushottaman dwarkanathan
Greenhorn

Joined: Apr 26, 2005
Posts: 25
Hi All,

I have an issue searching the following directory structure
dc = corsolutions
|
|
|
ou =groups
|
|
below groups we have the following three groups
1.Distribution Groups
2.RemoteForward
3. Security Groups - ACL

I am interested in this particular group
ou - Security Groups - ACL
|
|
CN = ITDevelopment
|
|
below this contained name we have the following attributes
objectclass =group
member = CN=Miller\Scott,OU=Information Technology etc

when i search in this specific fashion

String[] attrIDs = {"member"};
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(attrIDs);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);


String filter = "(&(cn=ITDevelopment,ou=groups, ou=Security Groups - ACL ")(objectClass=group))";


NamingEnumeration answer = ctx.search("dc=corsolutions,dc=com", filter, ctls);

I am getting the name not found exception for this group

Security Groups - ACL

however if i just list till the group level in this fashion
context.list("ou=groups");

I am able to see all the groups below it

1.Distribution Groups
2.RemoteForward
3. Security Groups - ACL

Kindly give some suggestions. I think it is not able to resolve the spaces existing in the groups.


IBM Certified SOA Associate
purushottaman dwarkanathan
Greenhorn

Joined: Apr 26, 2005
Posts: 25
Hi All,

I was able to solve this issue.. I did a search based on the sAMAccountName and listed the attributes I was searching for.

I was able to successfully fetch all the information of the

a sample snippet:

//the attribute id to fetch
String[] attributeIDs = {"member"};
//create an instance of the search control
SearchControls ctls = new SearchControls();
//set the attribute id to be expected in the result
ctls.setReturningAttributes(attributeIDs);
//set the search scope to all the levels below the base entry
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
// filter sAMAccountName corresponds to the CN name ITDevelopment
String filter = "(&(sAMAccountName=ITDevelopment)( objectclass=group))";
//gives a handle to the naming enumeration of the directory structure
NamingEnumeration contentsEnum = context.search("", filter, ctls);

Thought this will be helpful for other members, if such a situation arises.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI Active Directory Search issue