summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/auth
diff options
context:
space:
mode:
authorAlfred Schmid <A.Schmid@ff-muenchen.de>2014-02-03 10:01:04 +0100
committerJames Moger <james.moger@gitblit.com>2014-02-19 11:04:16 -0500
commitf6d7de15b1471b1c101362dbaf598de8031e6540 (patch)
treef07d4635d35c97c2525ef48f8bb0d02435c9c976 /src/main/java/com/gitblit/auth
parentedae533cd47384c155485af74ef968453de69b9e (diff)
downloadgitblit-f6d7de15b1471b1c101362dbaf598de8031e6540.tar.gz
gitblit-f6d7de15b1471b1c101362dbaf598de8031e6540.zip
Load empty groups as empty teams from ldap, when ldap user
synchronization is enabled.
Diffstat (limited to 'src/main/java/com/gitblit/auth')
-rw-r--r--src/main/java/com/gitblit/auth/LdapAuthProvider.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/auth/LdapAuthProvider.java b/src/main/java/com/gitblit/auth/LdapAuthProvider.java
index 1ec273a9..b2084595 100644
--- a/src/main/java/com/gitblit/auth/LdapAuthProvider.java
+++ b/src/main/java/com/gitblit/auth/LdapAuthProvider.java
@@ -152,6 +152,9 @@ public class LdapAuthProvider extends UsernamePasswordAuthenticationProvider {
userManager.updateTeamModels(userTeams.values());
}
}
+ if (!supportsTeamMembershipChanges()) {
+ getEmptyTeamsFromLdap(ldapConnection);
+ }
lastLdapUserSync.set(System.currentTimeMillis());
} finally {
ldapConnection.close();
@@ -435,6 +438,27 @@ public class LdapAuthProvider extends UsernamePasswordAuthenticationProvider {
}
}
+ private void getEmptyTeamsFromLdap(LDAPConnection ldapConnection) {
+ String groupBase = settings.getString(Keys.realm.ldap.groupBase, "");
+ String groupMemberPattern = settings.getString(Keys.realm.ldap.groupEmptyMemberPattern, "(&(objectClass=group)(!(member=*)))");
+
+ SearchResult teamMembershipResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, null);
+ if (teamMembershipResult != null && teamMembershipResult.getEntryCount() > 0) {
+ for (int i = 0; i < teamMembershipResult.getEntryCount(); i++) {
+ SearchResultEntry teamEntry = teamMembershipResult.getSearchEntries().get(i);
+ if (!teamEntry.hasAttribute("member")) {
+ String teamName = teamEntry.getAttribute("cn").getValue();
+
+ TeamModel teamModel = userManager.getTeamModel(teamName);
+ if (teamModel == null) {
+ teamModel = createTeamFromLdap(teamEntry);
+ userManager.updateTeamModel(teamModel);
+ }
+ }
+ }
+ }
+ }
+
private TeamModel createTeamFromLdap(SearchResultEntry teamEntry) {
TeamModel answer = new TeamModel(teamEntry.getAttributeValue("cn"));
answer.accountType = getAccountType();