Guest User

Untitled

a guest
Jan 8th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public class CustomSSRSCredentials : IReportServerCredentials
  2. {
  3. private string _SSRSUserName;
  4. private string _SSRSPassWord;
  5. private string _DomainName;
  6.  
  7. public CustomSSRSCredentials(string UserName, string PassWord, string DomainName)
  8. {
  9. _SSRSUserName = UserName;
  10. _SSRSPassWord = PassWord;
  11. _DomainName = DomainName;
  12. }
  13.  
  14. public System.Security.Principal.WindowsIdentity ImpersonationUser
  15. {
  16. get { return null; }
  17. }
  18.  
  19. public ICredentials NetworkCredentials
  20. {
  21. get { return new NetworkCredential(_SSRSUserName, _SSRSPassWord, _DomainName); }
  22. }
  23.  
  24. public bool GetFormsCredentials(out Cookie authCookie, out string user,
  25. out string password, out string authority)
  26. {
  27. authCookie = null;
  28. user = password = authority = null;
  29. return false;
  30. }
  31. }
  32.  
  33. if (!Page.IsPostBack)
  34. {
  35. ReportViewer1.ProcessingMode = ProcessingMode.Remote;
  36. IReportServerCredentials ssrscredentials = new CustomSSRSCredentials("MyUserName", "MyPassword", "ServerName");
  37. ServerReport serverReport = ReportViewer1.ServerReport;
  38. ReportViewer1.ServerReport.ReportServerCredentials = ssrscredentials;
  39. serverReport.ReportServerUrl = new Uri("ReportPathKey");
  40. serverReport.ReportPath = "/Reports/MyReport";
  41. serverReport.Refresh();
  42. }
Add Comment
Please, Sign In to add comment