Merge pull request #586 from mposolda/master
Ensure that displayName is persisted. Add 'user' to ActiveDirectory clas...
This commit is contained in:
commit
3655db2a30
6 changed files with 25 additions and 3 deletions
|
@ -485,7 +485,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog,
|
|||
|
||||
if ($scope.lastVendor === "ad") {
|
||||
$scope.instance.config.usernameLDAPAttribute = "cn";
|
||||
$scope.instance.config.userObjectClasses = "person, organizationalPerson";
|
||||
$scope.instance.config.userObjectClasses = "person, organizationalPerson, user";
|
||||
} else {
|
||||
$scope.instance.config.usernameLDAPAttribute = "uid";
|
||||
$scope.instance.config.userObjectClasses = "inetOrgPerson, organizationalPerson";
|
||||
|
|
|
@ -781,8 +781,9 @@ public class RealmAdapter implements RealmModel {
|
|||
entity.setPriority(model.getPriority());
|
||||
String displayName = model.getDisplayName();
|
||||
if (displayName == null) {
|
||||
entity.setDisplayName(entity.getId());
|
||||
displayName = entity.getId();
|
||||
}
|
||||
entity.setDisplayName(displayName);
|
||||
em.persist(entity);
|
||||
realm.getUserFederationProviders().add(entity);
|
||||
|
||||
|
|
|
@ -766,6 +766,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
if (displayName == null) {
|
||||
displayName = entity.getId();
|
||||
}
|
||||
entity.setDisplayName(displayName);
|
||||
realm.getUserFederationProviders().add(entity);
|
||||
updateRealm();
|
||||
|
||||
|
@ -840,6 +841,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
if (displayName == null) {
|
||||
entity.setDisplayName(entity.getId());
|
||||
}
|
||||
entity.setDisplayName(displayName);
|
||||
entities.add(entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class LDAPConnectionTestManager {
|
|||
|
||||
ldapContext = new InitialLdapContext(env, null);
|
||||
return true;
|
||||
} catch (NamingException ne) {
|
||||
} catch (Exception ne) {
|
||||
String errorMessage = (TEST_AUTHENTICATION.equals(action)) ? "Error when authenticating to LDAP: " : "Error when connecting to LDAP: ";
|
||||
logger.error(errorMessage + ne.getMessage(), ne);
|
||||
return false;
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.keycloak.models.RealmModel;
|
|||
import org.keycloak.models.RequiredCredentialModel;
|
||||
import org.keycloak.models.RoleModel;
|
||||
import org.keycloak.models.SocialLinkModel;
|
||||
import org.keycloak.models.UserFederationProviderModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.services.managers.RealmManager;
|
||||
|
@ -194,6 +195,14 @@ public class ImportTest extends AbstractModelTest {
|
|||
Assert.assertEquals("abc", socialConfig.get("google.key"));
|
||||
Assert.assertEquals("def", socialConfig.get("google.secret"));
|
||||
|
||||
// Test federation providers
|
||||
List<UserFederationProviderModel> fedProviders = realm.getUserFederationProviders();
|
||||
Assert.assertTrue(fedProviders.size() == 1);
|
||||
UserFederationProviderModel ldap = fedProviders.get(0);
|
||||
Assert.assertEquals("MyLDAPProvider", ldap.getDisplayName());
|
||||
Assert.assertEquals("dummy", ldap.getProviderName());
|
||||
Assert.assertEquals(1, ldap.getPriority());
|
||||
Assert.assertEquals("ldap://foo", ldap.getConfig().get("important.config"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,6 +16,16 @@
|
|||
"google.key": "abc",
|
||||
"google.secret": "def"
|
||||
},
|
||||
"userFederationProviders": [
|
||||
{
|
||||
"displayName": "MyLDAPProvider",
|
||||
"providerName": "dummy",
|
||||
"priority": 1,
|
||||
"config": {
|
||||
"important.config": "ldap://foo"
|
||||
}
|
||||
}
|
||||
],
|
||||
"users": [
|
||||
{
|
||||
"username": "wburke",
|
||||
|
|
Loading…
Reference in a new issue