Sql-server – User in multiple windows groups mapped to sql logins

Securitysql serversql-server-2008-r2

I have two C# apps with Windows Auth to Microsoft SQL Server 2008 R2.

For every app:

  • SQL login based on Windows Group is created
  • SQL server login is mapped to SQL database user
  • user is member of a role
  • role has granted permissions to tables, views, procedures, etc.

Question is:

If I add a single windows user as a member to both windows groups (with are "mapped" to different SQL logins, which are mapped to different SQL users, which belongs to different roles and so on..) – could user run both apps without any problems or only one of them will work properly?

Best Answer

If I am understanding your question correctly, then yes the user will be able to run both applications with database connection issues.

If User1 is part of Windows Groups Group1 and Group2, and Group1 is mapped as a SQL Server login, as well as Group2 is mapped to a different SQL Server login. And if Group1 is mapped to a database user in Database1 and Group2 is mapped as a database user in Database2, then User1 should have access to both Database1 and Database2. And if Group1 and Group2 are both mapped to TheOnlyDatabase, then the user will have the accumulations of both database users' permissions.

This will return only one of the database users (as expected):

select user_name() as database_user_name

This will return 1 for both queries if the users is a member of both Windows Groups:

select is_member('Domain\Group1') as member_of_group_1

select is_member('Domain\Group2') as member_of_group_2