开发者

open ssrs report in Excel format via 'normal' url with webrequest returns 401

i want to download a ssrs report in Excel format in code.

So i first checked the url: it is correct then i created a webrequest, with a NetworkCredential for the same user which can open the link in the browser.

I moved developing to the ssrs machine itself ( it has vs2008 on it)

so now i'm on the ssrs machine, logge开发者_运维百科d on as user A, starting a webpage, create a webrequest with the same credentials as i'm currently logged on with to the ssrs machine (user A).... and get a 401.

What i don't know is what is giving me the 401. Is it the webserver denying me, or is it ssrs itself (i'm a newbee at ssrs so i don't know much about rights on reports in ssrs itself, but as i said: my logon credentials are the same as the webrequest credentials: user A).

i've googled a lot and tried 5 solutions, but no luck so far.


This won't work if NTLM credentials are required:

webrequest.Credential = new networkcredential ("","","");

You can try the following but it likely will not work:

webrequest.Credentials = CredentialCache.DefaultNetworkCredentials;

Chances are you will need to pass in the actual credentials like:

NetworkCredential networkCredential = new NetworkCredential(UserName, Password, Domain);
CredentialCache credCache = new CredentialCache();
credCache.Add(new Uri(url), "NTLM", networkCredential);
webrequest.Credentials = credCache;

SSRS will need to authentic the WebRequest and default/blank credentials cannot be passed in.


This reminded me of something I ran into a couple years ago: http://support.microsoft.com/kb/896861

I'm not sure how likely this problem is, but I really think it's worth implementing "Method 2" from that support article (a simple registry addition) just to see if that resolves the problem. (Yes, the article lists a bunch of old OS versions, but I successfully used this on a bunch of SharePoint 2007 servers to resolve problems.)

Worth a try, I think...


I always set

WebRequest.UseDefaultCredentials = True

Then I run the app as the user accessing the SSRS server.


At first I suggest installing Fiddler Web Debugger on the machine where the calling application is run. This way you can see exactly the requests and responses that are made between your application and the SSRS. You might find something like an ISA proxy wanting you to additionally authenticate to it.

Assuming your caller is a console or WebForms application, the following code passes the credentials under which your application runs to the SSRS:

        WebRequest webRequest = WebRequest.Create(url);
        HttpWebRequest httpWebRequest = webRequest as HttpWebRequest;

        // request authentication
        httpWebRequest.UseDefaultCredentials = true;
        // which is the same as
        httpWebRequest.Credentials = CredentialCache.DefaultCredentials;

        // optional proxy authentication
        httpWebRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜