Repository: incubator-ranger Updated Branches: refs/heads/master dca76775e -> 3a60d698a
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/3a60d698 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/3a60d698 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/3a60d698 Branch: refs/heads/master Commit: 3a60d698a7b946d1424772cd787ec4e956d7afb1 Parents: dca7677 Author: Velmurugan Periasamy <[email protected]> Authored: Fri Dec 4 19:41:56 2015 -0500 Committer: Velmurugan Periasamy <[email protected]> Committed: Fri Dec 4 19:45:20 2015 -0500 ---------------------------------------------------------------------- .../process/LdapUserGroupBuilder.java | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/3a60d698/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(); } }
