# How to detect that a user is locked with Admin Rest API?

**URL:** <https://forum.keycloak.org/t/how-to-detect-that-a-user-is-locked-with-admin-rest-api/16756>\
**Category:** Miscellanaeous\
**Created:** [August 4, 2022, 12:59pm UTC](https://forum.keycloak.org/t/how-to-detect-that-a-user-is-locked-with-admin-rest-api/16756 "2022-08-04T12:59:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [August 4, 2022, 12:59pm UTC](https://forum.keycloak.org/t/how-to-detect-that-a-user-is-locked-with-admin-rest-api/16756/1 "2022-08-04T12:59:18Z")

</div>

Hi  
when a user enters a wrong user name or password we get an error “Unauthorized - Invalid user credentials”  
which makes sense.

but in our configuration after 5 attempts the user is locked  
when we send another login with bad credentials we still get “Unauthorized - Invalid user credentials”, BUT we have no way to know that the user is locked at this point

someone already asked this 5 years ago in this [SOF post](https://stackoverflow.com/questions/41467004/keycloak-indicate-user-is-temporarily-locked)

but I don’t get the answer he received.

for example, one option is to send:  
**GET /{realm}/attack-detection/brute-force/users/{userId}**  
but I have 2 problems with this approach:

1. I don’t have the userId. I have the user name
2. in order to invoke this endpoint I need to be authenticated - which is a paradox since I’m handling with a failed login attempt

is there no other way to understand that a user is locked?

---

<div class="post-metadata">

**Author:** ![BradleyS](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@BradleyS](https://forum.keycloak.org/u/BradleyS)\
**Post date:** [May 23, 2023, 7:05pm UTC](https://forum.keycloak.org/t/how-to-detect-that-a-user-is-locked-with-admin-rest-api/16756/2 "2023-05-23T19:05:05Z")

</div>

Hi @amir. Did you ever figure this out?
