Problem with 'execute as login' on running stored procedure

  • Hi Everyone.

    We have a sp1 which is being called by User1. In this SP there are some tables that User1 does not have access to them, so I have to create another user2 and give proper permission to that user.

    when I ran the sp1 while I am login by User1 with 'execute as login = 'User2'',I recieved below error message:

    Cannot execute as the server principal because the principal "User2" does not exist, this type of principal cannot be impersonated, or you do not have permission.

    But if I ran the same statment while I login as sysadmin , I dont have any problem.

    I would appreciate if someone help me on this.

    Thanks

  • User1 must be given permission to impersonate user2, but I'd like to understand why ownership chaining[/url] isn't sufficient in this case, so please answer the following questions:

    1. Are all the objects in the same database?

    2. What schemas are the objects in?

    3. Who owns the schemas?

    SELECT

    S.name AS SchemaName,

    DP.name AS OwnerName

    FROM

    sys.schemas AS S

    JOIN sys.database_principals AS DP

    ON S.principal_id = DP.principal_id;

    If the schemas have the same owner ownership chaining should work.

  • Please don't create multiple posts for the same problem.

    Answer here

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply