Repository: incubator-ranger
Updated Branches:
  refs/heads/ranger-0.5 e9dd40803 -> 299cbfaef


RANGER-742 : Removed the dependency on groupUserMapSyncEnabled flag (Sailaja 
Polavarapu via Velmurugan Periasamy)

Signed-off-by: Velmurugan Periasamy <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/299cbfae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/299cbfae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/299cbfae

Branch: refs/heads/ranger-0.5
Commit: 299cbfaef81afa10da2ba719871dcf78381833d4
Parents: e9dd408
Author: Velmurugan Periasamy <[email protected]>
Authored: Fri Dec 4 19:41:56 2015 -0500
Committer: Velmurugan Periasamy <[email protected]>
Committed: Fri Dec 4 19:46:14 2015 -0500

----------------------------------------------------------------------
 .../process/LdapUserGroupBuilder.java           | 21 ++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/299cbfae/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/LdapUserGroupBuilder.java
----------------------------------------------------------------------
diff --git 
a/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/LdapUserGroupBuilder.java
 
b/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/LdapUserGroupBuilder.java
index bb5fad5..99403d7 100644
--- 
a/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/LdapUserGroupBuilder.java
+++ 
b/ugsync/src/main/java/org/apache/ranger/ldapusersync/process/LdapUserGroupBuilder.java
@@ -473,8 +473,8 @@ public class LdapUserGroupBuilder implements 
UserGroupSource {
        private void getUserGroups(UserGroupSink sink) throws Throwable {
                NamingEnumeration<SearchResult> groupSearchResultEnum = null;
                LOG.debug("Total No. of users saved = " + userGroupMap.size());
-               if (groupSearchEnabled && groupUserMapSyncEnabled) {
-                       LOG.info("groupSearch and groupUserMapSync are enabled, 
would search for groups and compute memberships");
+               if (groupSearchEnabled) {
+                       LOG.info("groupSearch is enabled, would search for 
groups and compute memberships");
                        createLdapContext();
                }
                
@@ -482,10 +482,8 @@ public class LdapUserGroupBuilder implements 
UserGroupSource {
                while(userInfoIterator.hasNext()) {
                        UserInfo userInfo = userInfoIterator.next();
                        String userName = userInfo.getUserName();
-                       if (groupSearchEnabled && groupUserMapSyncEnabled) {
-                               //LOG.info("groupSearch and groupUserMapSync 
are enabled, would search for groups and compute memberships");
+                       if (groupSearchEnabled) {
                                try {
-                                       
                                                groupSearchResultEnum = 
ldapContext
                                                                
.search(groupSearchBase, extendedGroupSearchFilter,
                                                                                
new Object[]{userInfo.getUserFullName()},
@@ -494,8 +492,15 @@ public class LdapUserGroupBuilder implements 
UserGroupSource {
                                                while 
(groupSearchResultEnum.hasMore()) {
                                                        final SearchResult 
groupEntry = groupSearchResultEnum.next();
                                                        if (groupEntry != null) 
{
-                                                               String gName = 
(String) groupEntry.getAttributes()
-                                                                               
.get(groupNameAttribute).get();
+                                                               Attribute 
groupNameAttr = groupEntry.getAttributes() != null? 
groupEntry.getAttributes().get(groupNameAttribute) : null;
+                                                               if 
(groupNameAttr == null) {
+                                                                       if 
(LOG.isInfoEnabled())  {
+                                                                               
LOG.info(groupNameAttribute + " empty for entry " + 
groupEntry.getNameInNamespace() +
+                                                                               
                ", skipping sync");
+                                                                       }
+                                                                       
continue;
+                                                               }
+                                                               String gName = 
(String) groupNameAttr.get();
                                                                if 
(groupNameCaseConversionFlag) {
                                                                        if 
(groupNameLowerCaseFlag) {
                                                                                
gName = gName.toLowerCase();
@@ -529,7 +534,7 @@ public class LdapUserGroupBuilder implements 
UserGroupSource {
                                + ", groups: " + groupList);
                        }
                }
-               if (groupSearchEnabled && groupUserMapSyncEnabled) {
+               if (groupSearchEnabled) {
                        closeLdapContext();
                }
        }

Reply via email to