Showing posts with label sysadmin. Show all posts
Showing posts with label sysadmin. Show all posts

Friday, March 9, 2012

logins

How can I write a script to generate the list of SQL users that have sysadmin privileges. I would also like to do the same for the windows accounts as well.

Please let me know.

Thanks.

Hi,

SELECT CASE WHEN isntname = 1 OR isntgroup = 1 OR isntuser = 1 THEN 'WindowsLogin' ELSE 'SQLLogin' END

FROM syslogins

WHERE sysadmin = 1

HTH, Jens Suessmeyer,

http://www.sqlserver2005.de

|||

The catalog view syslogins has been deprecated in SQL Server 2005 (for more information visit "sys.syslogins (Transact-SQL)" in BOL http://msdn2.microsoft.com/en-us/library/ms178593.aspx).

For SQL 2005 I would recommend using the new catalog views. Here is a sample on how to get the role membership information.

-- Select all role members (fixed role name, member name)

--

SELECT suser_name( role_principal_id ) as server_fixed_role_name,

suser_name( member_principal_id ) as member_login_name

FROM sys.server_role_members

ORDER BY role_principal_id

go

-- Select all role members

-- (fixed role name, member type, member name)

--

SELECT suser_name( sysrolemembers.role_principal_id ) as server_fixed_role_name,

principals.type_desc as member_login_type,

principals.name as member_login_name

FROM sys.server_role_members sysrolemembers,

sys.server_principals principals

WHERE sysrolemembers.member_principal_id = principals.principal_id

ORDER BY sysrolemembers.role_principal_id, principals.type_desc, principals.name

go

Thanks a lot,

-Raul Garcia

SDE/T

SQL Server Engine

|||

Note that both queries in the above answers will miss Windows users that are not "directly" sysadmins, but inherit their sysadmin property from a Windows group to which they belong.

Thanks
Laurentiu

Friday, February 24, 2012

Login problem by not being in sysadmin group

Hi All

I experience a very strange login problem:

I create standard security login, let say test1/test1 with a default db test and assign it sysadmin group.

All is working well.

The moment remove sysadmin group from this login, i start getting errors:

Login failed for user 'test1'

... when I login from remote server. If I login from the same host - it continues with no problem.

When I go to sql server configuration manager, I see next:

sql native client configuration(32bit):

shared memeory enabled

tcp/ip enabled

named pipes enabled

VIA disabled

The same settings from sql server 2005 network configuration / protocols for mssqlserver

sql native client configuration / client protocols

sql 2005 surface area configuration / remote connections is configured:

local and remote connections (checked), using both tcp/ip and named pipes.

Does anybody have a clue?

What is the default database for your login?

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

Hi Wesley

Default db is named 'test'. I made sure login has default db and can browse it.

|||

Try changing the default database to master. If you can then connect with that login, there is a problem with the users access to what you were using for the default database.

-Sue

Login problem by not being in sysadmin group

Hi All

I experience a very strange login problem:

I create standard security login, let say test1/test1 with a default db test and assign it sysadmin group.

All is working well.

The moment remove sysadmin group from this login, i start getting errors:

Login failed for user 'test1'

... when I login from remote server. If I login from the same host - it continues with no problem.

When I go to sql server configuration manager, I see next:

sql native client configuration(32bit):

shared memeory enabled

tcp/ip enabled

named pipes enabled

VIA disabled

The same settings from sql server 2005 network configuration / protocols for mssqlserver

sql native client configuration / client protocols

sql 2005 surface area configuration / remote connections is configured:

local and remote connections (checked), using both tcp/ip and named pipes.

Does anybody have a clue?

What is the default database for your login?

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

Hi Wesley

Default db is named 'test'. I made sure login has default db and can browse it.

|||

Try changing the default database to master. If you can then connect with that login, there is a problem with the users access to what you were using for the default database.

-Sue