Bonjour je fais une classe qui recherche des utilisateurs et des groupes dans l'AD, mais je n'arrive à descendre que d'un groupe dans les OU,
comment faire pour descendre plus bas.

Je m'explique, j'arrive à chercher dans :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
"OU=Groups,DC=home,DC=maboite,DC=fr"
mais pas dans :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
"OU=grouplvl1,OU=Groups,DC=home,DC=maboite,DC=fr"
Mon code est :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
this.name=n;
		this.pwd=p;
 
 
		try {
		    Hashtable env = new Hashtable();
		    env.put(Context.INITIAL_CONTEXT_FACTORY,
		             "com.sun.jndi.ldap.LdapCtxFactory");
		    env.put(Context.PROVIDER_URL,
		             "ldap://maboite.fr"); //replace with your server URL/IP
		             //only DIGEST-MD5 works with our Windows Active Directory
		    env.put(Context.SECURITY_AUTHENTICATION,
		             "DIGEST-MD5"); //No other SALS worked with me
		    env.put(Context.SECURITY_PRINCIPAL,
		            name); // specify the username ONLY to let Microsoft Happy
		    env.put(Context.SECURITY_CREDENTIALS, pwd);   //the password
 
		    DirContext ctx = new InitialDirContext(env);
 
		   // ctx.getNameInNamespace();
 
		  //  System.out.println("Name : "+ctx.U);
 
 
 
		    //Create the search controls 		
			SearchControls searchCtls = new SearchControls();
 
			//Specify the attributes to return
			//String returnedAtts[]={"sn","givenName","mail"};
			String returnedAtts[]={"sn","givenName","mail"};
			searchCtls.setReturningAttributes(returnedAtts);
 
			//Specify the search scope
			searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
 
			//specify the LDAP search filter
			String searchFilter = "(&(objectClass=*)(mail=*))";
 
			//Specify the Base for the search
 
			String searchBase = "OU=grouplvl1,OU=Groups,DC=home,DC=maboite,DC=fr";
 
 
			//initialize counter to total the results
			int totalResults = 0;
 
 
			// Search for objects using the filter
			NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
 
			//Loop through the search results
			while (answer.hasMoreElements()) {
		    		SearchResult sr = (SearchResult)answer.next();
 
				totalResults++;
 
				System.out.println(">>>" + sr.getName());
 
				// Print out some of the attributes, catch the exception if the attributes have no values
				Attributes attrs = sr.getAttributes();
 
				if (attrs != null) {
					try {
					System.out.println("   surname: " + attrs.get("sn").get());
					System.out.println("   firstname: " + attrs.get("givenName").get());
					System.out.println("   mail: " + attrs.get("mail").get());
 
					} 
					catch (NullPointerException e)	{
					System.out.println("Errors listing attributes: " + e);
					}
				}
 
			}
 
 			System.out.println("Total results: " + totalResults);
 
 
 
		    ctx.close();
 
		  } catch(NamingException ne) {
		    System.out.println("Error authenticating user:");
		    System.out.println(ne.getMessage());
 
		    return connect;
		}
 
		  //if no exception, the user is already authenticated.
		  connect=1;
 
		  return connect;
 
	}