diff --git a/src/main/java/sh/libre/scim/core/ScimClient.java b/src/main/java/sh/libre/scim/core/ScimClient.java index 3551c5070e..7b28823d0d 100644 --- a/src/main/java/sh/libre/scim/core/ScimClient.java +++ b/src/main/java/sh/libre/scim/core/ScimClient.java @@ -72,6 +72,10 @@ public class ScimClient { M kcModel) { var adapter = getAdapter(aClass); adapter.apply(kcModel); + // If mapping exist then it was created by import so skip. + if (adapter.query("findById", adapter.getId()).getSingleResult() != null) { + return; + } var retry = registry.retry("create-" + adapter.getId()); var resource = retry.executeSupplier(() -> { try { diff --git a/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java b/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java index 081a1c6dac..272fc48f03 100644 --- a/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java +++ b/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java @@ -110,13 +110,9 @@ public class ScimStorageProviderFactory RealmModel realm = session.realms().getRealm(realmId); session.getContext().setRealm(realm); var client = new ScimClient(model, session); - model.setEnabled(false); - realm.updateComponent(model); client.sync(UserAdapter.class, result); client.sync(GroupAdapter.class, result); client.close(); - model.setEnabled(true); - realm.updateComponent(model); } });