Dolibarr/dolibarr · error
ErrorCantLoadUserFromDolibarrDatabase
Error message
ErrorCantLoadUserFromDolibarrDatabase (${login}) What it means
Authentication succeeded against the auth backend, but fetching the corresponding user record from the Dolibarr database returned 0 rows ($resultFetchUser == 0). Dolibarr stores ErrorCantLoadUserFromDolibarrDatabase with the login name and fires USER_LOGIN_FAILED. The credentials may be valid externally (e.g. HTTP/LDAP) but no matching Dolibarr user exists.
Solutions
- Create the user in Dolibarr (Users & Groups > New User) with the same login used by the auth backend.
- Check the selected entity matches where the user record lives (multicompany).
- If the user was deleted, restore or recreate the account.
- Verify the auth module's login-to-Dolibarr user mapping.
- Note: resultFetchUser==0 means not found; <0 means a DB error whose message is stored instead.
Example fix
// before: LDAP login 'jdoe' valid but no user row exists // after: create a user card in Dolibarr with login 'jdoe' in the correct entity
Defensive patterns
Strategy: validation
Validate before calling
$tmp = new User($db);
if ($tmp->fetch('', $login) <= 0) { die("No Dolibarr user for login '$login'; create it or fix auth mapping"); } Prevention
- Provision Dolibarr users together with directory accounts (same login convention)
- Audit entity assignments after enabling multicompany
- Monitor USER_LOGIN_FAILED triggers for recurring not-found logins
When it happens
Trigger: Login validated by an external auth mode (http, ldap, oauth) whose login has no row in the user table for the given entity; user deleted in Dolibarr while still valid in the directory; multicompany entity mismatch so the fetch misses the user.
Common situations: LDAP/SSO deployments where directory accounts were never provisioned as Dolibarr users; users deleted in Dolibarr but still in LDAP; wrong entity chosen on multicompany logins.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
- ErrorBadValueForCode
- ErrorBadLoginPassword
- ErrorLoginDateValidity
- If define NOREQUIREDB or NOREQUIRETRAN are set, you must…
- If define NOREQUIREUSER is set, you must also set…
AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14).
Data as JSON: /api/errors/e4ea2e9f564b6746.
Report an issue: GitHub.
Appendix: source
Thrown at htdocs/main.inc.php:890
dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); // This include http headers
}
exit;
}
$resultFetchUser = $user->fetch(0, $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); // value for $login was retrieved previously when checking password.
if ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) {
dol_syslog('User not found or not valid, connection refused');
session_destroy();
session_set_cookie_params(0, '/', null, !empty($dolibarr_main_force_https), true); // Add tag secure and httponly on session cookie
session_name($sessionname);
dol_session_start();
if ($resultFetchUser == 0) {
// Load translation files required by page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorCantLoadUserFromDolibarrDatabase", $login);
$user->context['audit'] = 'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
} elseif ($resultFetchUser < 0) {
$_SESSION["dol_loginmesg"] = $user->error;
$user->context['audit'] = $user->error;
} else {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
$user->context['audit'] = $langs->trans("ErrorLoginDateValidity").' - login='.$login;
}
// Call trigger
$result = $user->call_trigger('USER_LOGIN_FAILED', $user);
if ($result < 0) {View on GitHub (pinned to 598aa4bdad)