public CdwConnection(DataSource ds) : base(ds) { this.Account = new CdwAccount(this); ImpersonationCredentials credentials = new ImpersonationCredentials(); _impersonationUser = credentials.RunAsUser; }
public void ActivateItem(string key, IDbConnection item) { if (item.State.Equals(ConnectionState.Open)) { return; } try { using (ImpersonationCodeSection section = new ImpersonationCredentials(key).LogOn()) { item.ConnectionString = key; item.Open(); } } catch (Exception e) { throw new PoolLifeCycleException("Failed to activate item", e); } }
protected void BindServerReport(MsServerReport serverReport, IReport report) { IRemoteReportProcessingLocation location = (IRemoteReportProcessingLocation)report.ReportProcessingLocation; try { // ReSharper disable once UnusedVariable using (ImpersonationCodeSection i = ImpersonationCredentials.FromConnectionString("AnalysisServices").LogOn()) { serverReport.ReportPath = location.Path; serverReport.ReportServerUrl = location.ServerUrl; if (serverReport.IsDrillthroughReport) { // do not need to handle the callback } else { IList <MsReportParameter> parameters = new List <MsReportParameter>(); foreach (IReportParameter parameter in report.ReportParameters) { parameters.Add(new MsReportParameter(parameter.Name, GetParameterValue(parameter))); } serverReport.SetParameters(parameters); } serverReport.Refresh(); } } catch { // can do nothing ? } }