logins and groups
-
Monday, April 16, 2012 8:39 AM
Hi Team,
How can i get all the groups and all the logins in the instance.
can you guy please provide me, a script for this.
Thanks in advance..
tx
subu
All Replies
-
Monday, April 16, 2012 8:37 AM
Hi Team,
How can i get all the groups and all the logins in the instance.
can you guy please provide me, a script for this.
Thanks in advance..
tx
subu
- Merged by VidhyaSagar Monday, April 16, 2012 2:18 PM Thread started by same user
-
Monday, April 16, 2012 8:42 AM
sys.server_principals
sys.server_role_members
- Edited by Alexey KnyazevMVP Monday, April 16, 2012 8:42 AM
- Proposed As Answer by Ben Seaman Monday, April 16, 2012 10:35 AM
-
Monday, April 16, 2012 8:45 AMAnswererselect name,type_desc from sys.server_principals
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
-
Monday, April 16, 2012 8:56 AM
Hi You can use this query as per your requirmentSELECT P.NAME AS DATABASE_ROLE, DP.NAME AS DATABASE_USER FROM SYS.DATABASE_ROLE_MEMBERS RM JOIN SYS.DATABASE_PRINCIPALS P ON (RM.ROLE_PRINCIPAL_ID = P.PRINCIPAL_ID) JOIN SYS.DATABASE_PRINCIPALS DP ON (RM.MEMBER_PRINCIPAL_ID = DP.PRINCIPAL_ID)
------------------ Please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Maqbool.
-
Monday, April 16, 2012 9:33 AM
Hi Team,
I have tried the bove scripts but no luck.. can you please see below output
RSExecRole DEVWEB\sql2k8svc
db_owner dbo
db_owner DEVWEB\NAEAST Webops Oncall
db_owner ReportUser
db_datareader DEVWEB\CIGISTbut i am expecting all groups and all logins with out duplicate
can you please help me on this.
subu
-
Monday, April 16, 2012 9:36 AM
Hi URi,
as per your suggestion i have follow but no luck i m getting all login and users and groups every thing i will get .
i m expecting all Groups in a instance with out duplictae
all logins with in a instance with out duplicate.
subu
-
Monday, April 16, 2012 10:34 AM
Hi,
What is wrong with Alexey's suggestion of sys.server_principals? I believe this answers your question. The following query shows you all the logins in the instance (assuming you have the appropriate permissions to see them) and the type of login (which will be one of SQL_LOGIN, WINDOWS_LOGIN, WINDOWS_GROUP, SERVER_ROLE, CERTIFICATE_MAPPED_LOGIN, ASYMMETRIC_KEY_MAPPED_LOGIN).
SELECT name, type_desc FROM sys.server_principals
Ben
-
Monday, April 16, 2012 11:06 AM
you can use this one
select name,loginname, isntgroup,* from sys.syslogins
-
Monday, April 16, 2012 11:59 AM
why do you've 2 thread started?
this thread is the same as this one logins and groups and you got the answers there in a single place.
Could a Moderator merge those two threads?
-
Monday, April 16, 2012 2:23 PM
If you are looking for script to retrieve permission then you can try the scripts below
http://sql-articles.com/scripts/script-to-retrieve-security-information-sql-server-2005-and-above/
Mark as ANSWER if I helped you today :-)
- Marked As Answer by Kalman TothMicrosoft Community Contributor, Moderator Friday, April 20, 2012 7:53 PM
-
Monday, April 16, 2012 3:29 PM
Hi Team,
I m sorry for posinng this same question in other plances because
last Friday i have posted i should not get any suggestions from the team that is the reason i have posted same questions in other also
appologies from my end i have trouble to the team
Thanks guys..
subu
-
Monday, April 16, 2012 5:19 PM
Hi Team,
I m sorry for posinng this same question in other plances because
last Friday i have posted i should not get any suggestions from the team that is the reason i have posted same questions in other also
appologies from my end i have trouble to the team
Thanks guys..
subu
don't mind about posting it in 2 forums. The problem with 2 thread is that you get different oder duplicate answer to your question.
Apart from that, have your question been answered or what is still unanswered?

