ssrs master.dbo.xp_fileexist get different result based on user account

陌路散爱 提交于 2019-12-10 23:18:19

问题


SSRS dataset uses a query with a udf "fc_FileExists" to check user's photo existence. if the photo doesn't exist, will use anonymous photo. (the anonymous photo is at the same folder with other photos). This ssrs report is running in intranet domain environment. When I run this report, I can see photo. but some other users can't. They just see the anonymous photo. The code is like below.

CASE WHEN dbo.fc_FileExists('\\domain\folder\'+ID+'.jpg') = 1 
    THEN 'file:\\domain\folder\'+ID+'.jpg'
     WHEN dbo.fc_FileExists('\\domain\folder\'+ID+'.jpg') = 0 
    THEN 'file:\\domain\folder\anonymous .jpg'

Problem is for some user, they always get anonymous photos. That means the photo could exist there but dbo.fc_FileExists always return 0. But why I can see the photo.

Any help please

AND The source code for fc_FileExists is as below:

CREATE FUNCTION [dbo].[fc_FileExists](@path varchar(8000)) 
RETURNS BIT
AS
BEGIN
     DECLARE @result INT
     EXEC master.dbo.xp_fileexist @path, @result OUTPUT
     RETURN cast(@result as bit)
END;

回答1:


It's one of two things:

  1. Permissions: some users do not have permission to view the folder.
  2. The ID does not exist in the table.

If at all possible, connect to SQL Query Analyser as a user that shows the anonymous photo and then run the function - any errors? If not, as the same user try using windows explorer to find the users picture.




回答2:


I figured that this is not good way. Actually ssrs can use System.IO.File.Exists directly. So we don't have to do this job at sql server side. I think the performance should be better.



来源:https://stackoverflow.com/questions/38487345/ssrs-master-dbo-xp-fileexist-get-different-result-based-on-user-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!