private ValidatedResponse<CatalogItem> GetReportObjectFromSSRS(string reportName) { CatalogItem catalogItem; var client = new ReportingService2010SoapClient(); try { // Get EndPoint Address from AppSettings. Log.Information("GetReportObjectFromSSRS : Getting the report object {@reportName}", reportName); var trustedUserHeader = new RS2010.TrustedUserHeader(); client.Endpoint.Address = this.reportService2010Reference; client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; client.ClientCredentials.Windows.ClientCredential = null; client.Open(); Log.Information("GetReportObjectFromSSRS : Reporting Service 2010 Soap Client Uri - {@uri}", this.reportService2010Reference.Uri); //// I need to list of children of a specified folder. CatalogItem[] items; client.ListChildren(trustedUserHeader, "/", true, out items); catalogItem = (from CatalogItem ci in items where ci.TypeName.Contains("Report") && ci.Name.Equals(reportName, StringComparison.OrdinalIgnoreCase) select ci).FirstOrDefault(); Log.Information("GetReportObjectFromSSRS : Catalog Item {@catalogItem} was successfully obtained", catalogItem.Name); Log.Information("GetReportObjectFromSSRS : Successfully obtained Report Object"); return ValidatedResponse<CatalogItem>.Success(catalogItem); } catch (Exception ex) { Log.Error(ex, "GetReportObjectFromSSRS: Something went wrong in getting the SSRS Report Object - {@reportname}", reportName); return ValidatedResponseHelper.Failure<CatalogItem>("Error {0}", ex.ToString()); } finally { client.Close(); } }
private void test_1() { NetworkCredential clientCredentials = new NetworkCredential("Chathuranga", "blahhhhh", "Chathu-Nable"); ReportingService2010SoapClient client = new ReportingService2010SoapClient(); client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; client.ClientCredentials.Windows.ClientCredential = clientCredentials; client.Open(); TrustedUserHeader t = new TrustedUserHeader(); CatalogItem[] items; // I need to list of children of a specified folder. ServerInfoHeader oServerInfoHeader = client.ListChildren(t, "/", true, out items); foreach (var item in items) { // I can access any properties of item Console.WriteLine(item.ID); } Console.ReadLine(); }
public CatalogItem[] ListReportCollection(string itemPath, bool recursive) { CatalogItem[] reportCollection = { }; try { ReportingService2010SoapClient client = new ReportingService2010SoapClient(); //NT LAN Manager (NTLM) is a suite of Microsoft security protocols that provides authentication, integrity, and confidentiality to users.[1][2][3] NTLM is the successor to the authentication protocol in Microsoft LAN Manager (LANMAN), client.ClientCredentials.Windows.AllowNtlm = true; client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; // // Summary: // The server process can impersonate the client's security context on its local // system. The server cannot impersonate the client on remote systems. // Impersonation = 3, // Finally figure it out. // My Reporting Services were configured to a local account while my Application Pool for IIS was configured to ApplicationPoolIdentity. // I changed my Application Pool to LocalSystem and it fixed it. Hopefully this information will be useful to others as I wasted several hours figuring this out. client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; CatalogItem aCatalogItem = new CatalogItem(); // aCatalogItem.TypeName // Summary: // The server process can impersonate the client's security context on remote // systems. // client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation; client.Open(); TrustedUserHeader t = new TrustedUserHeader(); try { // I need to list of children of a specified folder. client.ListChildren(t, itemPath, recursive, out reportCollection); // see http://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.listchildren.aspx } catch (SoapException ex) { // _logger.Error("ReportServerManagementService--" + ex); } } catch (SoapException ex) { // _logger.Error("ReportServerManagementService--" + ex); } return(reportCollection); }
private SSRSServiceHandler() { NetworkCredential clientCredentials = new NetworkCredential("Test", "123", "Chathu-Nable"); serviceClient = new ReportingService2010SoapClient(); serviceClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; serviceClient.ClientCredentials.Windows.ClientCredential = clientCredentials; serviceClient.Open(); userHeader = new TrustedUserHeader(); }
/// <summary> /// Initializes a new instance of ReportServices to retrieve reports, /// to download and upload reports, etc. /// </summary> /// <param name="reportServerUrl"></param> /// <param name="login"></param> /// <param name="password"></param> /// <param name="domain"></param> public ReportServices(string reportServerUrl, string login, string password, string domain) { string url = reportServerUrl; if (!url.EndsWith("/") && !url.EndsWith(".asmx")) { url += "/ReportService2010.asmx"; } else if (!url.EndsWith(".asmx")) { url += "ReportService2010.asmx"; } NetworkCredential user = String.IsNullOrEmpty(domain) ? new NetworkCredential(login, password) : new NetworkCredential(login, password, domain); var binding = new System.ServiceModel.BasicHttpBinding(); binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Ntlm; binding.Security.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.None; binding.Security.Message.ClientCredentialType = System.ServiceModel.BasicHttpMessageCredentialType.UserName; binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; binding.MaxReceivedMessageSize = 65536999; binding.MaxBufferSize = 65536999; binding.SendTimeout = new TimeSpan(0, 0, 0, 20); binding.OpenTimeout = new TimeSpan(0, 0, 0, 20); binding.ReaderQuotas.MaxStringContentLength = 10000; binding.ReaderQuotas.MaxDepth = 10000; binding.ReaderQuotas.MaxArrayLength = 10000; var endpoint = new System.ServiceModel.EndpointAddress(url); _service = new ReportingService2010SoapClient(binding, endpoint); _service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; _service.ClientCredentials.Windows.ClientCredential = user; _service.Open(); }
private void grantPriviledges_2() { NetworkCredential clientCredentials = new NetworkCredential("Test", "123", "Chathu-Nable"); ReportingService2010SoapClient client = new ReportingService2010SoapClient(); client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; client.ClientCredentials.Windows.ClientCredential = clientCredentials; client.Open(); TrustedUserHeader t = new TrustedUserHeader(); Policy [] arrPolicies = null; bool doesInheritParent = false; client.GetPolicies(t, "/New Folder", out arrPolicies, out doesInheritParent); List <Policy> listPolicies = new List <Policy>(); if (arrPolicies != null) { listPolicies = arrPolicies.ToList(); } listPolicies.Add( new Policy() { Roles = new[] { new Role() { Name = "Browser" }, new Role() { Name = "Content Manager" } }, GroupUserName = "******" } ); client.SetPolicies(t, "/New Folder", listPolicies.ToArray()); /* * * Policy[] MyPolicyArr = new Policy[2]; * * * Role[] MyRoles = new Role[3]; * * Role browser = new Role(); * browser.Name = "Browser"; * * Role myReports = new Role(); * myReports.Name = "My Reports"; * * Role publisher = new Role(); * publisher.Name = "Publisher"; * * Role contentManager = new Role() { Name = "Content Manager" }; * * MyRoles[0] = publisher; * MyRoles[1] = browser; * MyRoles[2] = contentManager; * * * MyPolicyArr[0] = new Policy() { GroupUserName = @"Chathu-Nable\Test", Roles = MyRoles }; * MyPolicyArr[1] = new Policy() { GroupUserName = @"Chathu-Nable\Test2", Roles = MyRoles }; * * * client.SetPolicies(t, "/New Folder", MyPolicyArr); * * //rs.SetPolicies("/SecurityTestFolder", MyPolicyArr); * */ //MessageBox.Show(policies.Length + "") ; }
private void grantPriviledges_1() { NetworkCredential clientCredentials = new NetworkCredential("Test", "123", "Chathu-Nable"); ReportingService2010SoapClient client = new ReportingService2010SoapClient(); client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; client.ClientCredentials.Windows.ClientCredential = clientCredentials; client.Open(); TrustedUserHeader t = new TrustedUserHeader(); Policy[] MyPolicyArr = new Policy[2]; Role[] MyRoles = new Role[3]; Role browser = new Role(); browser.Name = "Browser"; Role myReports = new Role(); myReports.Name = "My Reports"; Role publisher = new Role(); publisher.Name = "Publisher"; Role contentManager = new Role() { Name = "Content Manager" }; MyRoles[0] = publisher; MyRoles[1] = browser; MyRoles[2] = contentManager; MyPolicyArr[0] = new Policy() { GroupUserName = @"Chathu-Nable\Test", Roles = MyRoles }; MyPolicyArr[1] = new Policy() { GroupUserName = @"Chathu-Nable\Test2", Roles = MyRoles }; client.SetPolicies(t, "/New Folder", MyPolicyArr); //rs.SetPolicies("/SecurityTestFolder", MyPolicyArr); MessageBox.Show("blahhhh"); }