Orphaned database users


Job details

Name: Orphaned database users
Platform: Sqlserver
Category: Security
Premium package: Security and compliance package
Description: Checks if there are orphaned database users (users for which the corresponding SQL Server login is undefined).
Long description: Checks if there are orphaned database users (users for which the corresponding SQL Server login is undefined).
Version: 1.21
Default schedule: 19 1 1 *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2005′ & hasengine=‘YES’ & eng_inst_priv = 0 & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
return status 1 Return status value (ALARM – 2, WARNING – 1, or OK – 0) if there are orphaned database users (users for which the corresponding SQL Server login is undefined).
revoke CONNECT NO If set to “YES“ the alert will revoke “CONNECT“ permission for orphaned users by running “REVOKE CONNECT FROM guest”.
history threshold 365 The maximum number of days to keep statistics for in the historic tables.
max users per graph 5 The maximum number of users visualized in the report graphs.

Job Summary

SELECT dp.name AS UserName, dp.type_desc AS UserType
  FROM sys.database_principals AS dp
  LEFT JOIN sys.server_principals AS sp ON dp.sid = sp.sid
  WHERE sp.sid IS NULL AND dp.type IN ('S', 'U', 'G')

Implementation Details

Reporting Features

Dependency Tables

Description Object Type Object Name Cleanup on Fail
Main procedure Stored Procedure dbw_orphan_db_user_proc true
Current status table Table dbw_orphan_database_user_info true
History table Table dbw_orphan_database_user_histr true

Presentation Details

Enhanced Functionality in Updates

By systematically checking and reporting on orphaned database users, this job helps maintain robust security measures in SQL Server environments, ensuring that only authorized users have access to databases.