Test LDAP User Search

Prev Next
Post
/api/v1/ldap.testSearch
Premium tag

Test if a given username can be found in the LDAP server using the authentication and filter settings provided to Rocket.Chat. Make sure LDAP is enabled in Settings > LDAP > Enable before using this endpoint.

Permission required: test-admin-options.

Changelog

Version Description
9.0.0 Moved to premium plans. Requires a license with the ldap-enterprise module.
9.0.0 Added the LDAP_Bind_failed, LDAP_User_not_found, and LDAP_Multiple_users_found errors.
Header parameters
X-Auth-Token
stringRequired

The authenticated user token.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The authenticated user ID.

ExamplerbAXPnMktTFbNpwtJ
Body parameters
Example 1
{
  "username": "bob"
}
object
username
string Required

The username that you want to search.

Examplebob
Responses
200

OK

Success Example
{
  "message": "LDAP_User_Found",
  "success": true
}
object
message
string
success
boolean
400

Bad Request

Missing Username

Username missing

The request body doesn't include username.

{
  "success": false,
  "error": "must have required property 'username'",
  "errorType": "error-invalid-params"
}
Bind Failed

LDAP bind failed

Rocket.Chat couldn't bind to the LDAP server with the authentication user DN and password. details.error contains the LDAP server's error.

{
  "success": false,
  "error": "LDAP_Bind_failed",
  "details": {
    "error": "Invalid Credentials"
  }
}
User Not Found

User not found

No LDAP user matches the username. Wildcard characters in username are not expanded, so a search for * also returns this error.

{
  "success": false,
  "error": "LDAP_User_not_found"
}
Multiple Users Found

More than one user found

More than one LDAP user matches the username. details.total contains the number of matches.

{
  "success": false,
  "error": "LDAP_Multiple_users_found",
  "details": {
    "total": "2"
  }
}
License Required

Premium license required

The workspace doesn't have a premium license with the ldap-enterprise module.

{
  "success": false,
  "error": "This is an enterprise feature [error-action-not-allowed]",
  "errorType": "error-action-not-allowed"
}
Search Failed

Search failed

The search failed for another reason, for example the LDAP server is unreachable, the base DN doesn't exist, the search filter is invalid, or username is empty.

{
  "success": false,
  "error": "LDAP_search_failed"
}
LDAP Disabled

LDAP is disabled

LDAP is not enabled in the workspace (LDAP_Enable is off).

{
  "success": false,
  "error": "LDAP_disabled"
}
Expand All
object
success
boolean
error
string
errorType
string
details
object
error
string

The LDAP server's error. Returned with LDAP_Bind_failed.

total
string

The number of matching users. Returned with LDAP_Multiple_users_found.

401

Unauthorized

Authorization Error
{
  "success": false,
  "error": "You must be logged in to do this."
}
object
success
boolean
error
string
403

Forbidden

Permission Error

Missing permission

The user doesn't have the test-admin-options permission.

{
  "success": false,
  "error": "User does not have the permissions required for this action [error-unauthorized]"
}
object
success
boolean
error
string