none
[求助]关于CRM4.0 Plugin 访问SQL filtered views的问题 RRS feed

  • 问题

  • 大家好,

          我现在遇到这样一个问题,我在plugin中使用sql查询语句访问filtered views, 返回结果总是0行,后发现"NT AUTHORITY\NETWORK SERVICE"用户不是crm验证用户,为了解决此问题又在sql语句中添加了" SETUSER 'crm\administrator' select * from dbo.FilteredContact""EXECUTE AS USER = 'crm\administrator' select * from dbo.FilteredContact"后,发现有如下报错信息

    System.Data.SqlClient.SqlException: Setuser failed because of one of the following reasons: the database principal does not exist, its corresponding server principal does not have server access, this type of database principal cannot be impersonated, or you do not have permission.


    不知具体是什么原因造成的,比较困惑,希望能够得到大家的帮助,先谢谢了
    crm4.0学步
    2009年12月14日 14:34

答案

  • execute as login = ''crm\administrator';

    your sql;

    revert;


    ------------------------------------------------------------------------------------------------------
    Server or database principals other than sa or dbo can call EXECUTE AS.

    The user that calls the EXECUTE AS statement must have IMPERSONATE permissions on the target principal.


    SETUSER is restricted to members of the sysadmin fixed server role or db_owner fixed database role.
    2009年12月15日 5:38