You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/05/03 09:57:05 UTC

svn commit: r1098953 - in /incubator/lcf/branches/CONNECTORS-195: CHANGES.txt connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java

Author: kwright
Date: Tue May  3 07:57:05 2011
New Revision: 1098953

URL: http://svn.apache.org/viewvc?rev=1098953&view=rev
Log:
Code for ticket CONNECTORS-195.

Modified:
    incubator/lcf/branches/CONNECTORS-195/CHANGES.txt
    incubator/lcf/branches/CONNECTORS-195/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java

Modified: incubator/lcf/branches/CONNECTORS-195/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-195/CHANGES.txt?rev=1098953&r1=1098952&r2=1098953&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-195/CHANGES.txt (original)
+++ incubator/lcf/branches/CONNECTORS-195/CHANGES.txt Tue May  3 07:57:05 2011
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 0.3-dev =========================
 
+CONNECTORS-195: Active directory authority does not properly identify
+non-existing users on all versions of Java and all versions of AD.
+(Kadri Atalay, Karl Wright)
+
 CONNECTORS-192: Specification processing would sometimes be called
 without the specification data being posted.
 (Karl Wright)

Modified: incubator/lcf/branches/CONNECTORS-195/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-195/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java?rev=1098953&r1=1098952&r2=1098953&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-195/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java (original)
+++ incubator/lcf/branches/CONNECTORS-195/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java Tue May  3 07:57:05 2011
@@ -205,26 +205,39 @@ public class ActiveDirectoryAuthority ex
   {
     getSession();
 
-    //Create the search controls 		
-    SearchControls searchCtls = new SearchControls();
-
-    //Specify the search scope, must be base level search for tokenGroups
-    searchCtls.setSearchScope(SearchControls.OBJECT_SCOPE);
- 
     //specify the LDAP search filter
     String searchFilter = "(objectClass=user)";
 		
     //Specify the Base for the search
     String searchBase = parseUser(userName);
+
+    //Create the search controls for finding the user
+    SearchControls userSearchCtls = new SearchControls();
+
+    //Specify the search scope, must be base level search for users
+    userSearchCtls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+    //Specify the attributes to return
+    userSearchCtls.setReturningAttributes(new String[]{"sAMAccountName"});
+
+    //Create the search controls for finding the access tokens	
+    SearchControls searchCtls = new SearchControls();
+
+    //Specify the search scope, must be base level search for tokenGroups
+    searchCtls.setSearchScope(SearchControls.OBJECT_SCOPE);
  
     //Specify the attributes to return
-    String returnedAtts[] = {"tokenGroups","objectSid"};
-    searchCtls.setReturningAttributes(returnedAtts);
+    searchCtls.setReturningAttributes(new String[]{"tokenGroups","objectSid"});
 
     try
     {
-      //Search for objects using the filter
-      NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
+      // Search for users
+      NamingEnumeration answer = ctx.search(searchBase, searchFilter, userSearchCtls);
+      if (!answer.hasMoreElements())
+        return userNotFoundResponse;
+      
+      //Search for tokens
+      answer = ctx.search(searchBase, searchFilter, searchCtls);
 
       ArrayList theGroups = new ArrayList();
       // All users get certain well-known groups