-1

다음은 SQL 서버 dba에 대한 요구 사항입니다.SQL 서버 사용자 권한 감사

누가 액세스 할 수 있는지 감사하는 프로세스가 마련되어 있습니다. 이 포함될 수 있습니다

1) 서버 로그인

2) 로컬 관리자

3) SQL 서버 수준의 역할, 특히 시스템 관리자

4) 데이터베이스 DBO, 독자, 작가

5) 마스터, msdb 액세스

6) 사용자 계정에서 연결된 서버 사용

공공 에

7) 명시 적 보조금 등

사람은 어떻게

감사 위 달성하는 스리

답변

1

당신은 시스템 테이블/뷰와 함께 작동하도록해야합니다 날을 제공하시기 바랍니다 수 없습니다. 기본 테이블 중 하나 (실제로보기)는 [master].[sys].[server_principals]이며 사용자가 검색됩니다.

권한이 있으므로 [master].[sys].[server_permissions]을 유용하게 사용할 수 있으며 역할을 찾을 수있는 곳은 [master].[sys].[server_role_members]입니다. 여기서 데이터베이스를 찾을 수 있습니다. [master].[sys].[sysdatabases]

사용자와 관련하여 principalid를 기록해 두십시오.

또한 각 데이터베이스에서 당신은 [Table].[sys].[sysusers][Table].[sys].[syslogins]

당신은 당신이 당신의 응용 프로그램에 필요한 것을 얻기 위해 자신의 일을 할 것 같은 전망을 찾을 수 있습니다. 위의 표에 관한 책과 온라인에서 많은 정보를 얻을 수 있습니다.

0

나는 내 자신의 질문에 대한 시도하고 아래에있는 내 목적을 해결

set nocount on 
declare @permission table (
Database_Name sysname, 
User_Role_Name sysname, 
Account_Type nvarchar(60), 
Action_Type nvarchar(128), 
Permission nvarchar(60), 
ObjectName sysname null, 
Object_Type nvarchar(60) 
) 
declare @dbs table (dbname sysname) 
declare @Next sysname 
insert into @dbs 
select name from sys.databases order by name 
select top 1 @Next = dbname from @dbs 
while (@@rowcount<>0) 
begin 
insert into @permission 
exec('use [' + @Next + '] 
declare @objects table (obj_id int, obj_type char(2)) 
insert into @objects 
select id, xtype from master.sys.sysobjects 
insert into @objects 
select object_id, type from sys.objects 

SELECT ''' + @Next + ''', a.name as ''User or Role Name'', a.type_desc as ''Account Type'', 
d.permission_name as ''Type of Permission'', d.state_desc as ''State of Permission'', 
OBJECT_SCHEMA_NAME(d.major_id) + ''.'' + object_name(d.major_id) as ''Object Name'', 
case e.obj_type 
when ''AF'' then ''Aggregate function (CLR)'' 
when ''C'' then ''CHECK constraint'' 
when ''D'' then ''DEFAULT (constraint or stand-alone)'' 
when ''F'' then ''FOREIGN KEY constraint'' 
when ''PK'' then ''PRIMARY KEY constraint'' 
when ''P'' then ''SQL stored procedure'' 
when ''PC'' then ''Assembly (CLR) stored procedure'' 
when ''FN'' then ''SQL scalar function'' 
when ''FS'' then ''Assembly (CLR) scalar function'' 
when ''FT'' then ''Assembly (CLR) table-valued function'' 
when ''R'' then ''Rule (old-style, stand-alone)'' 
when ''RF'' then ''Replication-filter-procedure'' 
when ''S'' then ''System base table'' 
when ''SN'' then ''Synonym'' 
when ''SQ'' then ''Service queue'' 
when ''TA'' then ''Assembly (CLR) DML trigger'' 
when ''TR'' then ''SQL DML trigger'' 
when ''IF'' then ''SQL inline table-valued function'' 
when ''TF'' then ''SQL table-valued-function'' 
when ''U'' then ''Table (user-defined)'' 
when ''UQ'' then ''UNIQUE constraint'' 
when ''V'' then ''View'' 
when ''X'' then ''Extended stored procedure'' 
when ''IT'' then ''Internal table'' 
end as ''Object Type'' 
FROM [' + @Next + '].sys.database_principals a 
left join [' + @Next + '].sys.database_permissions d on a.principal_id = d.grantee_principal_id 
left join @objects e on d.major_id = e.obj_id 
order by a.name, d.class_desc') 
delete @dbs where dbname = @Next 
select top 1 @Next = dbname from @dbs 
end 
set nocount off 
select * from @permission