How does SQL Server handle logins when there is ambiguity, for example, logins exist for a Windows user account and for the AD group that contains this user?
We had a small permission issue in SQL Server 2008 with Windows users from our Active Directory and groups from this AD. I will try to explain with an example.
Imagine a Windows domain user DOMAIN\myUser , which belongs to the AD DOMAIN\SomeGroup .
In SQL Server, I have 2 databases SomeAppDb and PublicDb .
The aim is that all users who are members of DOMAIN\SomeGroup , can have access to PublicDb , but only DOMAIN\myUser should have access to SomeAppDb .
Initially, the SQL login DOMAIN\SomeGroup was created in the instance in SQL Server (mapped to the AD group), and the user was created in the PublicDb database with the proper membership in the roles, and this worked, users from the SomeGroup group could access the required data in PublicDb .
For the needs of the new application, we want to provide explicit access for db SomeAppDb to the user DOMAIN\myUser , while maintaining access to PublicDb . Therefore, we created a Windows account in SQL Server for DOMAIN\myUser , and the user was created in the SomeAppDb database, with a mapping between 2.
From now on, myUser can access SomeAppDb as expected, but could not get longer access to PublicDb , and we had an error, for example:
Cannot open database "PublicDb" requested by the login. The login failed. Login failed for user 'DOMAIN\myUser'
My intuition tells me that when a user accesses an instance of SQL Server, SQL Server sees that the login is the same as the Windows user and ignores the login that exists for the group to which the user belongs.
One approach is to explicitly add access to db PublicDb for user myUser, but I would prefer to avoid this solution because it forces updating PublicDb every time we want to provide access to new users, which is exactly what we tried avoid initially ... (we did it as a temporary fix, hoping to find a better option).
Has anyone else encountered this problem? is there a better approach?
early