I have set up a Service bus 1.1 for windows server and trying to access it using the following code.
var sbUriList = new List<Uri>() { new UriBuilder { Scheme = "sb", Host = ServerFQDN, Path = ServiceNamespace }.Uri };
var httpsUriList = new List<Uri>() { new UriBuilder { Scheme = "https", Host = ServerFQDN, Path = ServiceNamespace, Port = HttpPort }.Uri };
NetworkCredential credential = new NetworkCredential("<User Name>", "<Password>", "<Domain>");
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((s, cert, chain, ssl) => { return true; });
TokenProvider tokenProvider = TokenProvider.CreateOAuthTokenProvider(httpsUriList, credential);
messageFactory = MessagingFactory.Create(sbUriList, tokenProvider);
ServiceBusConnectionStringBuilder connBuilder = new ServiceBusConnectionStringBuilder();
connBuilder.ManagementPort = HttpPort;
connBuilder.RuntimePort = TcpPort;
connBuilder.Endpoints.Add(new UriBuilder() { Scheme = "sb", Host = ServerFQDN, Path = ServiceNamespace }.Uri);
connBuilder.StsEndpoints.Add(new UriBuilder() { Scheme = "https", Host = ServerFQDN, Port = HttpPort, Path = ServiceNamespace }.Uri);
namespaceManager = NamespaceManager.CreateFromConnectionString(connBuilder.ToString());
if (!namespaceManager.QueueExists(queuename))
{
namespaceManager.CreateQueue(queuename);
}
this works fine if i run my code from a console application, but however if I put this in a windows service and run it under either a Local service or Local System the code throws the following exception while trying to check if the queue exists in the following line namespaceManager.QueueExists(queuename).
Unexpected exception : System.UnauthorizedAccessException: The remote server returned an error: (401) Unauthorized. Manage claim is required for this operation..TrackingId:5be1365e-b4ae-4555-b81b-dcbef96be9d0_GIE11LT32PD622,TimeStamp:4/19/2015 3:51:28 PM ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult`1.<GetAsyncSteps>b__2d(GetAsyncResult`1 thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
--- End of inner exception stack trace ---
Can someone please help me understand what I am doing wrong?
Finally found the issue in my code, thought i'll share it in case anyone else has the same issue.
my issue was that in the namespace I had not set the token as below:
namespaceManager.Settings.TokenProvider = tokenProvider;
as a result of which it was using the wrong token for connection and hence the error.
Related
I have write the code get google could credential by below code for read google spreadsheet data:
public static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT, String spreadsheetCredentialURL)
throws IOException {
// Load client secrets.
InputStream in = new URL( awsBucketUrl+spreadsheetCredentialURL).openStream();
if (in == null) {
throw new FileNotFoundException("Resource not found: " + awsBucketUrl+spreadsheetCredentialURL);
}
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
in.close();
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8099).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
}
Now, when i am deploying this code to my develop environment on docker serve it is givin me below error:
2022-09-07 12:52:40.461 ERROR 1 --- [nio-8080-exec-6] o.s.b.w.servlet.support.ErrorPageFilter : Forwarding to error page from request [/google/spreadsheets-tabs/1Klc6IICWEiq-Oi9YEEbRxbqtEylJ4Ti0UtKNkieYo8Q] due to exception [Address already in us].
The same code is working on my local laptop environment.
anyone has any idea?
I am migrating a .net core 2.1 app from windows server to linux container. It uses SQL Server 2008 report server.
The old app version is running on IIS (windows server), application pool with identity configured (active directory user).
The new app version is running on an alpine container using kestrel .net core server standalone, no identity configured.
When the app tries to reach SQL Server 2008 report server there is an error:
LoadReport error: One or more errors occured. (NTLM authentication is not possible with default credentials on this platform.)
How can I configure credentials (username and password)(same one set in my old application pool) in my new app based on linux container?
Part of my appsettings.json:
"Reporting": {
"ServerUrl": "http://myserver/ReportServer",
"ReportPath": "/Folder/Reports/"
},
Part of the source code:
private ServerReport PrepararRelatorio()
{
ReportSettings settings = new ReportSettings
{
ReportServer = this.configuration["Reporting:ServerUrl"]
};
ServerReport serverReport = new ServerReport(settings);
return serverReport;
}
protected FileContentResult CarregarRelatorio(
string nomeRelatorio,
string extensao,
Dictionary<string,string> parametros)
{
var renderType = this.ObterTipoRenderizacao(extensao);
if (ReportRenderType.Null.Equals(renderType))
{
throw new BusinessException("Erro ao definir o tipo do arquivo a ser exportado.");
}
ServerReport serverReport = this.PrepararRelatorio();
ReportRequest request = new ReportRequest
{
RenderType = renderType,
Path = this.configuration["Reporting:ReportPath"] + nomeRelatorio,
Name = nomeRelatorio,
ExecuteType = ReportExecuteType.Export,
Parameters = parametros
};
ReportResponse response = serverReport.Execute(request);
if (response.Status != 0)
{
throw new BusinessException(response.Message);
}
return File(response.Data.Stream, response.Data.MimeType, nomeRelatorio + "." + extensao);
}
Microsoft don't provide support for .NET Core/.NET 5, since the SSRS
library is intricately linked with WebForms, which are no longer
supported.
Refer this link
Usually, we use NetworkCredential option to pass username and password while in ASP.NET MVC.
You can able to supply report server's username and password to ReportSettings.Credential as shown in below.
Configuration:
"Reporting": {
"ServerUrl": "http://myserver/ReportServer",
"ReportPath": "/Folder/Reports/",
"UserName": "xxxxxx",
"Password": "yyyyyy"
},
Source Code:
private ServerReport PrepararRelatorio()
{
ReportSettings settings = new ReportSettings
{
ReportServer = this.configuration["Reporting:ServerUrl"],
Credential = NetworkCredential(this.configuration["Reporting:UserName"], this.configuration["Reporting:Password"])
};
ServerReport serverReport = new ServerReport(settings);
return serverReport;
}
On making a SAML request the port number (443) is being stripped out of the Destination. I understand this is default behaviour of the URI object. However the SAML identity provider requires the destination includes the port number for validation.
How can I get the SAML builder to include the port? 443 is being stripped from https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso (see below)
Saml2Configuration samlconfig = GetSAMLConfig();
var samlRequest = new Saml2AuthnRequest(samlconfig);
samlRequest.AssertionConsumerServiceUrl = new Uri(_appConfiguration["Saml2:AssertionConsumerServiceUrl"]);
samlRequest.Destination = new Uri(_appConfiguration["Saml2:SingleSignOnDestination"]); // https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso
samlRequest.NameIdPolicy = new NameIdPolicy()
{
AllowCreate = false,
Format = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
SPNameQualifier = _appConfiguration["Saml2:SPNameQualifier"]
};
samlRequest.Conditions = new Condition();
samlRequest.Conditions.Items = new List<ITfoxtec.Identity.Saml2.Schemas.Conditions.ICondition>();
samlRequest.Conditions.Items.Add(new ITfoxtec.Identity.Saml2.Schemas.Conditions.AudienceRestriction() { Audiences = new List<Audience>() { new Audience() { Uri = _appConfiguration["Saml2:AllowedAudienceUris"] } } });
var bnd = binding.Bind(samlRequest);
It is possible to change the destination URL after the ToActionResult method has been called if you are using a Saml2RedirectBinding. And thereby overriding the default behavior.
Like this:
var action = binding.ToActionResult() as RedirectResult;
action.Url = action.Url.Replace("https://sit-api.eat.xxxxxx.xxxx.xx/samlsso", "https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso");
return action;
I Use StimulSoft Ver:2015.2 in my MVC Web Application
I Use This Code In My View :
#Html.Stimulsoft().RenderMvcViewerScripts();
<div>
#Html.Stimulsoft().StiMvcViewerFx(options: new StiMvcViewerFxOptions
{
Theme = StiThemeFx.Office2013,
Actions =
{
GetReportSnapshot = "GetReportSnapshotForPeriodic",
// ViewerEvent = "ViewerEvent",
//Interaction = "Interaction",
//DesignReport = "GetReportTemplate"
},
Appearance =
{
},
Toolbar =
{
ShowParametersButton = true
}
})
</div>
When I run the application it works correct in LocalNetwork but when I use microtech to redirect my Valid Ip To My Local and I run the web site from valid ip it gots error of:
Failed to load resource: the server responded with a status of 404 (Not Found)
Infact GetReportSnapshot = "GetReportSnapshotForPeriodic",not find on server with port 8818 or any other port
how can I redirect to Getreportsnapshot with same ip and port?
Which file should I insert this code?
You should use the UseRelativeUrls option if you change the server.
#Html.Stimulsoft().StiMvcViewerFx(options: new StiMvcViewerFxOptions
{
Server =
{
UseRelativeUrls = true
}
I am accessing Rackspace Cloud APIs.
I have one api call which authenticates me on the rackspace cloud.
The method works perfectly, however, from time to time, i get this exception, randomly :
The remote name could not be resolved: 'identity.api.rackspacecloud.com'
When i am not getting this exception, the method returns the expected result, as it should be.
Is there any specific reason why it does this?
Here is my .net code:
private async Task<XDocument> AuthenticateAsync()
{
XNamespace ns = "http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0";
XDocument doc =
new XDocument(
new XDeclaration("1.0", "UTF-8", "Yes"),
new XElement("auth",
new XElement(ns + "apiKeyCredentials",
new XAttribute("username", "the userName"),
new XAttribute("apiKey", "the apiKey")
)
)
);
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
StringContent content = new StringContent(doc.ToString(), Encoding.UTF8, "application/xml");
// i randomly get "The remote name could not be resolved" exception
HttpResponseMessage response = await client.PostAsync("https://identity.api.rackspacecloud.com/v2.0/tokens", content);
response.EnsureSuccessStatusCode();
string stringResponse = await response.Content.ReadAsStringAsync();
return XDocument.Parse(stringResponse);
}
}
This certainly sounds like a DNS failure. Can you configure your machine to use the Google DNS servers and try again?