forked from phires/reportsync
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ReportingServicesMgmt.cs
37 lines (35 loc) · 1.38 KB
/
ReportingServicesMgmt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using ReportSync.Properties;
using ReportSync.ReportService;
namespace ReportSync
{
public class ReportingServicesMgmt
{
private const string ServicesUrl = @"/ReportService2005.asmx";
public ReportingService2005 ReportingService { get; private set; }
public Dictionary<string, string> DataSources { get; set; }
public ReportingServicesMgmt(string url, string username, string password, bool integratedAuth)
{
var reportServerUrl = url.TrimEnd('/') + ServicesUrl;
DataSources = new Dictionary<string, string>();
ReportingService = new ReportingService2005 {Url = reportServerUrl};
if (!integratedAuth)
{
var nameParts = username.Split('\\', '/');
if (nameParts.Length > 2)
{
throw new Exception(Resources.Incorrect_destination_user_name);
}
ReportingService.Credentials = nameParts.Length == 2
? new System.Net.NetworkCredential(nameParts[1], password, nameParts[0])
: new System.Net.NetworkCredential(username, password);
}
else
{
ReportingService.Credentials = System.Net.CredentialCache.DefaultCredentials;
}
}
}
}