Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2004, 12:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default Security Listing

Is there a XP or SP in SQL 2K that will give you a list of all the users defined on that server and what their security rights are in each database on that server?


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
__________________
Hal Levy
 
Old March 29th, 2004, 04:33 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

you can find current users is the master database table sysusers. It is normally not recommend querying system tables. Also
EXEC sp_helpsrvrolemember 'sysrole'

example: EXEC sp_helpsrvrolemember 'sysadmin'

 
Old March 29th, 2004, 05:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

ok-= lets go about it this way.

We are trying to create a report that lists all the Local users, NT users or NT Groups with access to SQL server and what rights they have.

Is there anything in SQL server that will help me do that?


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old March 29th, 2004, 05:52 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Ok,

here a script that will do what you need
set nocount on
declare @name sysname,
    @SQL nvarchar(600)

if exists (select [id] from tempdb..sysobjects where [id] = OBJECT_ID ('tempdb..#tmpTable'))
    drop table #tmpTable

CREATE TABLE #tmpTable (
    [DATABASENAME] sysname NOT NULL ,
    [USER_NAME] sysname NOT NULL,
    [ROLE_NAME] sysname NOT NULL)

declare c1 cursor for
    select name from master.dbo.sysdatabases

open c1
fetch c1 into @name
while @@fetch_status >= 0
begin
    select @SQL =
        'insert into #tmpTable
         select N'''+ @name + ''', a.name, c.name
        from ' + QuoteName(@name) + '.dbo.sysusers a
        join ' + QuoteName(@name) + '.dbo.sysmembers b on b.memberuid = a.uid
        join ' + QuoteName(@name) + '.dbo.sysusers c on c.uid = b.groupuid
        where a.name != ''dbo'''

        /* Insert row for each database */
        execute (@SQL)
    fetch c1 into @name
end
close c1
deallocate c1

select * from #tmpTable



http://www.sqlservercentral.com/scri...utions/276.asp
weirdMan

 
Old March 30th, 2004, 04:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

This is very close to what I need- however, it does not list people in the "public" role and it doesn't list people defined as System Administrators as users.. so this is much closer, but not complete. It's a great start.


Thanks!

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old March 30th, 2004, 04:43 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

from books online

 
Quote:
quote:public Role
Quote:
The public role is a special database role to which every database user belongs. The public role:

Captures all default permissions for users in a database.


Cannot have users, groups, or roles assigned to it because they belong to the role by default.


Is contained in every database, including master, msdb, tempdb, model, and all user databases.


Cannot be dropped.




Sal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Access Security & Role Based Security robzyc C# 6 April 11th, 2008 02:31 AM
Listing 8-10 and Listing 8-16. Asp.Net BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 February 6th, 2008 01:11 PM
Listing 16-8 smiller BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 5 October 24th, 2006 08:39 AM
System.Security.SecurityException: Security error coolcatjk Pro VB.NET 2002/2003 4 March 2nd, 2006 06:00 PM
Listing 6-17 simonh ASP.NET 2.0 Professional 1 February 12th, 2006 02:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.