• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

Trigger causing error "Server Principal is not able to access the database under the current secuirty context"

Just as the title describes.

Basically we have a third party application that is entering data into a table.  They have their own SQL login that is locked down just to the database created for that application to dump the data to.

Then, off of one of the tables that data gets inserted, we have a trigger, that selectively parses the data and inserts it into another table in another database using a different user.  We'll call this UserB.

The problem is that when the trigger runs, we get Server Principal 'UserB' is not able to access the database 'dbName' under the current secuirty context.

UserB has FULL access to dbName, I even tried it as DB owner.  Google has not been much help.  I tried taking Collation off of the database details, that didn't work.

The trigger is run:

      WITH EXECUTE AS 'UserB'
      AFTER INSERT

Any ideas?  Sql Server 2008 R2 by the way.
0
hscast
Asked:
hscast
  • 2
2 Solutions
 
tim_csCommented:
Did you give the owner of Database1 AUTHENTICATE permission on Database2  or set Trustworthy to on for Database1?
0
 
tim_csCommented:
0
 
Anthony PerkinsCommented:
You need to allow Cross-Database Ownership Chaining on both databases, as in:
ALTER DATABASE SourceDatabaseName SET DB_CHAINING ON
ALTER DATABASE TargetDatabaseName SET DB_CHAINING ON
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now