diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java index c42f74c43a..5ad113600d 100755 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java @@ -7,7 +7,6 @@ import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelException; import org.keycloak.models.RealmModel; import org.keycloak.models.RoleModel; -import org.keycloak.models.SocialLinkModel; import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserModel; import org.picketlink.idm.IdentityManagementException; @@ -28,12 +27,14 @@ import java.util.Map; import java.util.Set; /** + * @author Marek Posolda * @author Bill Burke * @version $Revision: 1 $ */ public class LDAPFederationProvider implements UserFederationProvider { private static final Logger logger = Logger.getLogger(LDAPFederationProvider.class); public static final String LDAP_ID = "LDAP_ID"; + public static final String SYNC_REGISTRATIONS = "syncRegistrations"; protected KeycloakSession session; protected UserFederationProviderModel model; @@ -86,12 +87,13 @@ public class LDAPFederationProvider implements UserFederationProvider { } @Override - public boolean isRegistrationSupported() { - return true; + public boolean synchronizeRegistrations() { + return "true".equalsIgnoreCase(model.getConfig().get(SYNC_REGISTRATIONS)); } @Override public UserModel register(RealmModel realm, UserModel user) { + if (!synchronizeRegistrations()) throw new IllegalStateException("Registration is not supported by this ldap server"); IdentityManager identityManager = getIdentityManager(); try { @@ -100,6 +102,7 @@ public class LDAPFederationProvider implements UserFederationProvider { picketlinkUser.setLastName(user.getLastName()); picketlinkUser.setEmail(user.getEmail()); identityManager.add(picketlinkUser); + user.setAttribute(LDAP_ID, picketlinkUser.getId()); return proxy(user); } catch (IdentityManagementException ie) { throw convertIDMException(ie); diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java index 155c2a0d66..969d9b2363 100755 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java @@ -11,6 +11,7 @@ import java.util.Collections; import java.util.List; /** + * @author Marek Posolda * @author Bill Burke * @version $Revision: 1 $ */ diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js index 0161019b13..2b17931e07 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js @@ -434,7 +434,6 @@ module.controller('GenericUserFederationCtrl', function($scope, $location, Notif }); - module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, realm, instance, UserFederationInstances, RealmLDAPConnectionTester) { console.log('LDAPCtrl'); @@ -445,6 +444,9 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.instance.providerName = "ldap"; $scope.instance.config = {}; $scope.instance.priority = 0; + $scope.syncRegistrations = false; + } else { + $scope.syncRegistrations = instance.config.syncRegistrations && instance.config.syncRegistrations == "true"; } $scope.ldapVendors = [ @@ -464,6 +466,14 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.lastVendor = $scope.instance.config.vendor; + $scope.$watch('syncRegistrations', function() { + if ($scope.syncRegistrations) { + $scope.instance.config.syncRegistrations = "true"; + } else { + $scope.instance.config.syncRegistrations = "false"; + } + }) + $scope.$watch('instance', function() { if (!angular.equals($scope.instance, instance)) { $scope.changed = true; @@ -510,6 +520,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.instance.providerName = "ldap"; $scope.instance.config = {}; $scope.instance.priority = 0; + $scope.syncRegistrations = false; } $scope.changed = false; $scope.lastVendor = $scope.instance.config.vendor; diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html index 9916be562e..ffac6b7ab0 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html @@ -33,6 +33,12 @@ +