Not able to get information of trusted domain user which is member

import javax.naming.ldap.*;

import javax.naming.directory.*;

import javax.naming.*;

import javax.naming.directory.BasicAttributes;

import java.util.Properties;

public class test {

public static void main(String[] args) {

Properties env = new Properties();

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://PUNOAADSVR:389");

env.put(Context.SECURITY_AUTHENTICATION,"simple");

env.put(Context.SECURITY_PRINCIPAL, "XXXXXX");

env.put(Context.SECURITY_CREDENTIALS, "XXXXXX");

try {

LdapContext context = new InitialLdapContext(env, null);

String base = "DC=punoadom,DC=avaya,DC=com";

String filter = "(&(objectClass=group)(CN=Uoaadmin))";

SearchControls controls = new SearchControls();

String []strReturningAttr = {"member"};

controls.setReturningAttributes(strReturningAttr);

controls.setSearchScope(SearchControls.SUBTREE_SCOPE);

NamingEnumeration answer = context.search(base, filter, controls);

int totalResults = 0;

String strMember ;

BasicAttributes userattrs;

// ... process attributes ...

while (answer.hasMoreElements()) {

SearchResult sr = (SearchResult)answer.next();

System.out.println(">>>" + sr.getName());

//Print out the groups

Attributes attrs = sr.getAttributes();

if (attrs != null) {

try {

for (NamingEnumeration ae = attrs.getAll();ae.hasMore();) {

Attribute attr = (Attribute)ae.next();

System.out.println("Attribute: " + attr.getID());

for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {

strMember = (String) e.next();

System.out.println(" " + totalResults + ". " + strMember);

userattrs = (BasicAttributes)context.getAttributes(strMember);

}

}

}

catch (NamingException e) {

System.err.println("Problem listing membership: " + e);

}

}

}

System.out.println("TotalResults " + totalResults );

}

catch (NamingException e) {

System.out.println("Problem retrieving RootDSE: " + e);

}

}

}

Oriso_Solutions,

I am getting following error

>>>CN=Uoaadmin,OU=OA Admins

Attribute: member

0. CN=biadmin99,OU=OA Admins,DC=punoadom1,DC=avaya,DC=com

Problem listing membership: javax.naming.PartialResultException: [LDAP: error code 10 - 0000202B: RefErr: DSID-0310063C, data 0, 1 access points

ref 1: 'punoadom1.avaya.com'

]; remaining name 'CN=biadmin99,OU=OA Admins,DC=punoadom1,DC=avaya,DC=com'

TotalResults 0

here biadmin99 is a user from punoadom1 which is trusted domain for punoadom

If I set searchscope to ONELEVEL_SCOPE this search returns me nothing.

How we set depth of search.

Please help me :(

[2910 byte] By [Abhijit_Ma] at [2007-11-27 10:40:01]
# 1

Problem solved !!!

by adding

env.put( Context.REFERRAL, "follow" );

and adding Cross-Reference of trusted domain

refer to this link

http://support.microsoft.com/kb/241737

Abhijit_Ma at 2007-7-28 19:04:26 > top of Java-index,Core,Core APIs...
# 2

Ohhhh Still have some problem :(

env.put(Context.SECURITY_PRINCIPAL,USERNAME);

env.put(Context.SECURITY_CREDENTIALS,Password);

here if USERNAME is from TRUSTED DOMAIN" ( made member of "Uoaadmin" group which is universal group on first domain).

It is able to find all members and their attributes of "Uoaadmin" group.

This group contains members from first domain and trusted domain.

But if USERNAME is from first domain it is giving me exception while finding user attributes of member from trusted domain

error is given below

CN=testuser,OU=OA Admins,DC=punoadom1,DC=pune,DC=com

Problem listing members: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece

here punoadom is first domain and punoadom1 is trusted domain

please help :(

adler_steven any idea ! or forum link ?

Abhijit_Ma at 2007-7-28 19:04:26 > top of Java-index,Core,Core APIs...
# 3

Have a read of the following posts:

"JNDI, Active Directory, Referrals and Global Catalog" available at

http://forum.java.sun.com/thread.jspa?threadID=603815&tstart=15

To kind of understand how to navigate through multiple domains, use the GC, chase referrrals etc.

and "JNDI, Active Directory and Group Memberships" at

http://forum.java.sun.com/thread.jspa?threadID=581444&tstart=150

to understand how group memberships work.

I also suggest searching some of the technical documentation on microsoft.com for further information on group memberships. Nested groups, group types (and their corresponding scope), multiple domains and forests makes enumeration of group memberships quite difficult.

adler_stevena at 2007-7-28 19:04:26 > top of Java-index,Core,Core APIs...