# Users import into keycloak from LDAP

**URL:** <https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728>\
**Category:** Getting advice\
**Tags:** ldap\
**Created:** [March 12, 2025, 6:27am UTC](https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728 "2025-03-12T06:27:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hema](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@Hema](https://forum.keycloak.org/u/Hema)\
**Post date:** [March 12, 2025, 6:27am UTC](https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728/1 "2025-03-12T06:27:18Z")

</div>

Hi everyone, we have configured the authentication in our application using keycloak which imports the users and credentials from LDAP . There are only around 1k registered users in LDAP server, but when we are checking in keycloak USER\_ENTITY table, there are more than 1 lakh records. This is clearly not in sync. We checked in the table but the ids and usernames are unique as well. How to solve this issue? And what might be the root cause of the issue

---

<div class="post-metadata">

**Author:** ![djordje](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/djordje/32/10815_2.png) [@djordje](https://forum.keycloak.org/u/djordje)\
**Post date:** [March 12, 2025, 1:22pm UTC](https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728/2 "2025-03-12T13:22:26Z")

</div>

In your User Federation settings, under LDAP settings, there is a two options:

1. Sync all users manually:  

2. Setup periodical sync:

---

<div class="post-metadata">

**Author:** ![Hema](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@Hema](https://forum.keycloak.org/u/Hema)\
**Post date:** [March 13, 2025, 5:49am UTC](https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728/3 "2025-03-13T05:49:18Z")

</div>

users syncing is not a problem. the number of users should actually be less than 10k in both LDAP and keycloak. Somehow , the number of users in keycloak(USER\_ENTITY table) is highly inflated(more than 1 lakh), where there are only less than 10k users registered in LDAP. how can we check on what basis the keycloak is importing users and why this much of increase is there.

---

<div class="post-metadata">

**Author:** ![djordje](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/djordje/32/10815_2.png) [@djordje](https://forum.keycloak.org/u/djordje)\
**Post date:** [March 13, 2025, 10:02am UTC](https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728/4 "2025-03-13T10:02:26Z")

</div>

check Users DN settings are you referencing good location of users:  
ou=users,dc=example,dc=com

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [March 13, 2025, 11:46am UTC](https://forum.keycloak.org/t/users-import-into-keycloak-from-ldap/29728/5 "2025-03-13T11:46:06Z")

</div>

If there are more users in Keycloak than in your LDAP, you won’t be able to determine this from the configuration only.  
Try to make a diff between usernames of your LDAP users and Keycloak users. Then, examine the difference (should be the additional users from KC, not in LDAP), from where they might originate.  
Do these users have a federation link set? If yes, where does it point to? If the target is the LDAP, then they just had to be existed in the LDAP at least once as they are available. Keycloak doesn’t create fake users or users that don’t exist. There must be reason/root cause somewhere. You will have to investigate manually!
