I want to create only one user on the domain, and my application should send that user and password to the reportviewer, in that way I wont have to give permissions to every user individually .
Does anyone have the lines of code to do this?
Try one of these articles:http://www.odetocode.com/Articles/215.aspx
http://www.odetocode.com/Articles/216.aspx|||Hey I STRUGGLED with this for some time and from grabbing other snippets of code and doing some of my own troubleshooting this is what I came up with and it works for me. Please note that in the second line of code you will need the IMPORTS of YOUR web service. I am using Webhost4life as my provider and this code works for me so I hope it helps someone out there to get started. If anyone has enhancements please let me know.
Imports Microsoft.VisualBasicImports com.mysite4now.sql332reportingImports Microsoft.Reporting.WebFormsImports System.Security.PrincipalPartialClass reportviewerInherits System.Web.UI.PagePublic Class ReportViewerCredentialsImplements IReportServerCredentialsPrivate _userNameAs String Private _passwordAs String Private _domainAs String Public Sub New(ByVal userNameAs String,ByVal passwordAs String,ByVal domainAs String) _userName = userName _password = password _domain = domainEnd Sub Public ReadOnly Property ImpersonationUser()As System.Security.Principal.WindowsIdentityImplements Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUserGet Return Nothing End Get End Property Public ReadOnly Property NetworkCredentials()As System.Net.ICredentialsImplements Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentialsGet Return New Net.NetworkCredential(_userName, _password, _domain)End Get End Property Public Function GetFormsCredentials(ByRef authCookieAs System.Net.Cookie,ByRef userNameAs String,ByRef passwordAs String,ByRef authorityAs String)As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials userName = _userName password = _password authority = _domainReturn Nothing End Function End Class Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not IsPostBackThen Dim rptPathAs String rptPath = Request("Path")Dim rsAs New ReportingService ReportViewer1.ServerReport.ReportServerCredentials =New ReportViewerCredentials("username","password","") ReportViewer1.ServerReport.ReportServerUrl =New Uri("yourservername") ReportViewer1.AsyncRendering =False ReportViewer1.ShowDocumentMapButton =True ReportViewer1.DocumentMapCollapsed =False ReportViewer1.ServerReport.ReportPath = rptPathEnd If End SubEnd Class|||
Hey, can i ask you for this line:
ReportViewer1.ServerReport.ReportServerCredentials = New ReportViewerCredentials("username", "password", "")
How you get the the password variable? if it from your database or from active directory?
Please advice, thank you.
|||you can put it in, web.config or from a database. don't know abt active directory.
I have worked with this, and we put it in web.config.
i haven't tried for active directory.
No comments:
Post a Comment