krishnamuttevi commented on code in PR #1162:
URL: https://github.com/apache/ranger/pull/1162#discussion_r3822762349
##########
ugsync/src/main/java/org/apache/ranger/unixusersync/process/PolicyMgrUserGroupBuilder.java:
##########
@@ -747,14 +747,26 @@ private void computeGroupDelta(Map<String, Map<String,
String>> sourceGroups) {
noOfModifiedGroups++;
groupNameMap.put(groupDN, groupName);
} else {
- if (MapUtils.isNotEmpty(curGroupAttrs) &&
!StringUtils.equalsIgnoreCase(groupDN, curGroupDN)) { // skip update
- LOG.debug("[{}]: SyncSource update skipped, current
group DN = {} new user DN = {}", groupName, curGroupDN, groupDN);
-
- if (StringUtils.equalsIgnoreCase(curGroupAttrsStr,
newGroupAttrsStr)) {
- groupNameMap.put(groupDN, groupName);
+ boolean isLdapAdSync =
StringUtils.equalsIgnoreCase(newSyncSource, "LDAP/AD")
+ && MapUtils.isNotEmpty(curGroupAttrs);
+
+ if (isLdapAdSync) {
+ // ALLOW the update. A DN change (like an OU move) is
normal for LDAP/AD.
+ LOG.debug("ALLOW UPDATE: LDAP/AD group moved. DN
changed (Current: {}, New: {}) for {}.", curGroupDN, groupDN, groupName);
+ // Notice there is NO continue; here, allowing it to
fall through to the update logic below.
+ if (!StringUtils.equalsIgnoreCase(groupDN,
curGroupDN)) {
+ groupNameMap.remove(curGroupDN);
}
+ }
+ else {
+ if (MapUtils.isNotEmpty(curGroupAttrs) &&
!StringUtils.equalsIgnoreCase(groupDN, curGroupDN)) { // skip update
+ LOG.debug("[{}]: SyncSource update skipped,
current group DN = {} new user DN = {}", groupName, curGroupDN, groupDN);
- continue;
+ if (StringUtils.equalsIgnoreCase(curGroupAttrsStr,
newGroupAttrsStr)) {
+ groupNameMap.put(groupDN, groupName);
+ }
+ continue;
+ }
}
if (StringUtils.isEmpty(curSyncSource) ||
(!StringUtils.equalsIgnoreCase(curGroupAttrsStr, newGroupAttrsStr) &&
StringUtils.equalsIgnoreCase(curSyncSource, newSyncSource))) { // update
Review Comment:
Thanks, I have modified and implemented the above suggestion before the
conditional block to reduce the computional overhead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]