on 06-07-2015 08:30 PM - edited on 09-17-2024 02:57 PM by Nils
This page explains how to resolve the following error: "Cannot connect to database, check your config file. Login failed for user lansweeperuser".
Lansweeper data, reports and settings are stored in a database. Your database is hosted in either the Microsoft SQL Compact, Microsoft SQL LocalDB or Microsoft SQL Server database server. If you install Lansweeper under SQL LocalDB or SQL Server, the installer automatically creates a SQL user called "lansweeperuser". This user is used by the Lansweeper scanning service and web console to connect to the database.
If lansweeperuser gets corrupted, or has its password changed without an accompanying update of the Lansweeper configuration files, the service and console will no longer be able to connect to the database and you may see errors like the one below. The error below indicates that, even though Lansweeper is able to find the SQL instance hosting the lansweeperdb database, it is unable to access the database with the lansweeperuser account. It's important to note that this does not point to database corruption or an issue with the database itself. It simply indicates that the database cannot be accessed to read or write information. To resolve this issue, lansweeperuser needs to be reset.
To reset lansweeperuser and have the service and console successfully connect to the database again, follow these steps:
/* Makes sure there are no objects in the lansweeperuser schema, so the lansweeperuser SQL user can be reset */
USE lansweeperdb
GO
DECLARE c_ALTSCHEMA CURSOR FOR
SELECT 'ALTER SCHEMA dbo TRANSFER lansweeperuser.'+name +';'
FROM sys.objects
WHERE SCHEMA_NAME(SCHEMA_ID) = 'lansweeperuser'
DECLARE @SQLStmt NVARCHAR(200)
OPEN c_ALTSCHEMA
FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC(@SQLStmt)
FETCH NEXT FROM c_ALTSCHEMA INTO @SQLStmt
END
CLOSE c_ALTSCHEMA
DEALLOCATE c_ALTSCHEMA
GO
/* Resets the lansweeperuser SQL user */
USE lansweeperdb
GO
DROP SCHEMA lansweeperuser
GO
DROP USER lansweeperuser
GO
EXECUTE sp_droplogin lansweeperuser
GO
USE MASTER
GO
EXEC sp_addlogin 'lansweeperuser', 'lansweeperuserpassword', 'lansweeperdb', [English]
GO
USE lansweeperdb
GO
EXEC sp_grantdbaccess 'lansweeperuser', 'lansweeperuser'
GO
EXEC sp_addrolemember [db_owner], 'lansweeperuser'
GO
Program Files (x86)\Lansweeper\Tools\ConfigEditor.exe
on the servers hosting your Lansweeper Server service and web console.
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try NowExperience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now