Saturday, 1 February 2014

SQL database for fetching informations at the installation level


List of users having administrative access to the database
Query:  exec sp_helpsrvrolemember @srvrolename = 'sysadmin'
 
Check the authentication mode for SQL database              
Query : DECLARE @AuthenticationMode INT
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer',   N'LoginMode',
@AuthenticationMode OUTPUT
 SELECT CASE @AuthenticationMode    WHEN 1 THEN 'Windows Authentication'
 WHEN 2 THEN 'SQL Server Authentication(Mixed Mode)'   ELSE 'Unknown'  END as [Authentication Mode]

Password policy for default sql user accounts
Query: select * from sys.sql_logins
 
Check permissions for the guest account on sensitive databases.
Query: SELECT dp.name, permission_name, sp.state_desc
FROM sys.database_principals dp
INNER JOIN sys.server_permissions sp
ON dp.principal_id = sp.grantee_principal_id
WHERE dp.name = 'guest'

No comments:

Post a Comment