{"record":{"id":"e4ea2e9f564b6746","repo":"Dolibarr/dolibarr","slug":"errorcantloaduserfromdolibarrdatabase-login","errorCode":null,"errorMessage":"ErrorCantLoadUserFromDolibarrDatabase (${login})","messagePattern":"ErrorCantLoadUserFromDolibarrDatabase \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"htdocs/main.inc.php","lineNumber":890,"sourceCode":"\t\t\t\tdol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : ''));\t// This include http headers\n\t\t\t}\n\t\t\texit;\n\t\t}\n\n\t\t$resultFetchUser = $user->fetch(0, $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); // value for $login was retrieved previously when checking password.\n\n\t\tif ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) {\n\t\t\tdol_syslog('User not found or not valid, connection refused');\n\t\t\tsession_destroy();\n\t\t\tsession_set_cookie_params(0, '/', null, !empty($dolibarr_main_force_https), true); // Add tag secure and httponly on session cookie\n\t\t\tsession_name($sessionname);\n\t\t\tdol_session_start();\n\n\t\t\tif ($resultFetchUser == 0) {\n\t\t\t\t// Load translation files required by page\n\t\t\t\t$langs->loadLangs(array('main', 'errors'));\n\n\t\t\t\t$_SESSION[\"dol_loginmesg\"] = $langs->transnoentitiesnoconv(\"ErrorCantLoadUserFromDolibarrDatabase\", $login);\n\n\t\t\t\t$user->context['audit'] = 'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;\n\t\t\t} elseif ($resultFetchUser < 0) {\n\t\t\t\t$_SESSION[\"dol_loginmesg\"] = $user->error;\n\n\t\t\t\t$user->context['audit'] = $user->error;\n\t\t\t} else {\n\t\t\t\t// Load translation files required by the page\n\t\t\t\t$langs->loadLangs(array('main', 'errors'));\n\n\t\t\t\t$_SESSION[\"dol_loginmesg\"] = $langs->transnoentitiesnoconv(\"ErrorLoginDateValidity\");\n\n\t\t\t\t$user->context['audit'] = $langs->trans(\"ErrorLoginDateValidity\").' - login='.$login;\n\t\t\t}\n\n\t\t\t// Call trigger\n\t\t\t$result = $user->call_trigger('USER_LOGIN_FAILED', $user);\n\t\t\tif ($result < 0) {","sourceCodeStart":872,"sourceCodeEnd":908,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/main.inc.php#L872-L908","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: LDAP login 'jdoe' valid but no user row exists\n// after: create a user card in Dolibarr with login 'jdoe' in the correct entity","handlingStrategy":"validation","validationCode":"$tmp = new User($db);\nif ($tmp->fetch('', $login) <= 0) { die(\"No Dolibarr user for login '$login'; create it or fix auth mapping\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["dolibarr","login","user-sync"],"backgroundTag":"user-not-found","analyzedSha":"598aa4bdada683d17ca04b1842548821ff0eb6c6","analyzedAt":"2026-09-14T11:12:15.309Z","contentChangedAt":"2026-09-14T11:12:15.309Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}