PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.db.ms-sqlserver > Re: Need w/ a script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: Need w/ a script

Réponse
 
LinkBack Outils de la discussion
Vieux 05/09/2007, 18h19   #1
click37@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need w/ a script

On Aug 21, 5:31 pm, Erland Sommarskog <esq...@sommarskog.se> wrote:
> (clic...@gmail.com) writes:
> > Is there a query that will let me see what SQL users has what access
> > to which DBs and what lvl access they have?

>
> Not a single query, as the login-user mapping for a database is stored
> within it. You need to query each database, although this can be packaged
> with sp_MSforeachdb. I started to write something, but then it occurred
> to me that you had not said which version of SQL Server you are using.
> And the solution is completely different for SQL 2000 and SQL 2005.
>


SQL 2000. It doesn't need to be a stored prod, a developer that I
know created a tool that will allow me to run a query across all
servers & DBs. .

> As for "what access" and "what lvl", you need to be more specific. The
> permission scheme in SQL 2005 is very fine-grained, and the query could
> be very complex - as could the output be.
>


I need to know if each user has dbo rights, db_reader/writer and so
forth.



> --
> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
>
> Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
> Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx



  Réponse avec citation
Vieux 05/09/2007, 22h39   #2
Erland Sommarskog
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need w/ a script

(click37@gmail.com) writes:
> SQL 2000. It doesn't need to be a stored prod, a developer that I
> know created a tool that will allow me to run a query across all
> servers & DBs. .
>
>> As for "what access" and "what lvl", you need to be more specific. The
>> permission scheme in SQL 2005 is very fine-grained, and the query could
>> be very complex - as could the output be.
>>

>
> I need to know if each user has dbo rights, db_reader/writer and so
> forth.


Here are two queries. The first gives you role membership in a database,
the second gives you permissions granted to objects. As for the column
action, look up what the numbers mean in the description of the system
table sysprotects in Books Online.

SELECT login = l.name, [User] = u.name, Role = g.name
FROM sysusers u
LEFT JOIN master..syslogins l ON u.sid = l.sid
JOIN sysmembers m ON m.memberuid = u.uid
JOIN sysusers g ON m.groupuid = g.uid
ORDER BY User, Role


SELECT login = l.name, [User] = u.name, object = o.name,
action = p.action
FROM sysusers u
LEFT JOIN master..syslogins l ON u.sid = l.sid
JOIN sysprotects p ON u.uid = p.uid
JOIN sysobjects o ON p.id = o.id
WHERE p.protecttype IN (204,205)
AND o.type <> 'S'
ORDER BY User, object, action


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
  Réponse avec citation
Vieux 05/09/2007, 22h39   #3
Erland Sommarskog
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need w/ a script

(click37@gmail.com) writes:
> SQL 2000. It doesn't need to be a stored prod, a developer that I
> know created a tool that will allow me to run a query across all
> servers & DBs. .
>
>> As for "what access" and "what lvl", you need to be more specific. The
>> permission scheme in SQL 2005 is very fine-grained, and the query could
>> be very complex - as could the output be.
>>

>
> I need to know if each user has dbo rights, db_reader/writer and so
> forth.


Here are two queries. The first gives you role membership in a database,
the second gives you permissions granted to objects. As for the column
action, look up what the numbers mean in the description of the system
table sysprotects in Books Online.

SELECT login = l.name, [User] = u.name, Role = g.name
FROM sysusers u
LEFT JOIN master..syslogins l ON u.sid = l.sid
JOIN sysmembers m ON m.memberuid = u.uid
JOIN sysusers g ON m.groupuid = g.uid
ORDER BY User, Role


SELECT login = l.name, [User] = u.name, object = o.name,
action = p.action
FROM sysusers u
LEFT JOIN master..syslogins l ON u.sid = l.sid
JOIN sysprotects p ON u.uid = p.uid
JOIN sysobjects o ON p.id = o.id
WHERE p.protecttype IN (204,205)
AND o.type <> 'S'
ORDER BY User, object, action


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
  Réponse avec citation
Vieux 06/09/2007, 15h35   #4
click37@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need w/ a script

On Sep 5, 5:39 pm, Erland Sommarskog <esq...@sommarskog.se> wrote:
> (clic...@gmail.com) writes:
> > SQL 2000. It doesn'tneedto be a stored prod, a developer that I
> > know created a tool that will allow me to run a query across all
> > servers & DBs. .

>
> >> As for "what access" and "what lvl", youneedto be more specific. The
> >> permission scheme in SQL 2005 is very fine-grained, and the query could
> >> be very complex - as could the output be.

>
> > Ineedto know if each user has dbo rights, db_reader/writer and so
> > forth.

>
> Here are two queries. The first gives you role membership in a database,
> the second gives you permissions granted to objects. As for the column
> action, look up what the numbers mean in the description of the system
> table sysprotects in Books Online.
>
> SELECT login = l.name, [User] = u.name, Role = g.name
> FROM sysusers u
> LEFT JOIN master..syslogins l ON u.sid = l.sid
> JOIN sysmembers m ON m.memberuid = u.uid
> JOIN sysusers g ON m.groupuid = g.uid
> ORDER BY User, Role
>
> SELECT login = l.name, [User] = u.name, object = o.name,
> action = p.action
> FROM sysusers u
> LEFT JOIN master..syslogins l ON u.sid = l.sid
> JOIN sysprotects p ON u.uid = p.uid
> JOIN sysobjects o ON p.id = o.id
> WHERE p.protecttype IN (204,205)
> AND o.type <> 'S'
> ORDER BY User, object, action
>
> --
> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
>
> Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
> Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx


Thank you sir! They worked like a charm and you saved me from having
to go thru every database :-). I owe u a coke!

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11002 seconds with 12 queries