Why SQL Login can access database without no associated database user?

TonyJK 881 Reputation points
2023-02-17T22:35:06.78+00:00

Hi,

We find that for a particular SQL Login, it can access a number of databases (FinanceDev and FinanceTest) even though we cannot find corresponding Database User. Is there any way for us to revoke the access for that particular SQL Login ?

On the other hand, we are not able to drop that SQL Login as somehow it is database owner of another database (FinanceProd). We have already raised another question as follow

https://learn.microsoft.com/en-us/answers/questions/1181620/accidentally-assign-db-owner-to-a-domain-user-unab

Your advice is sought.

SQL Server Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-02-17T23:33:45.5766667+00:00

    Presumably the user has access through an AD group.

    You can run this in the database:

    EXECUTE AS USER = 'DOMAIN\USER'
    SELECT name, type, usage
    FROM  sys.user_token
    REVERT
    
    

    This will list all security tokens that are associated with this user.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.