SMTP error could not Authenticated using SMTP in .Net core - asp.net-core

Credentials were Correct.
5.7.57 SMTP - Client was not authenticated to send mail, 535 5.7.139 Authentication unsuccessful
returning this error while sending email using SMTP in .Net
This Application is deployed in Azure
Not sure what is causing the issue, previoulsy it was working suddenly it stopped.
Tried with Exchange Server throwing 401 unAuthorized error.

That's because .NET SMTP class is old and doesn't support authentication.
Take a look at its cross platform replacement. Microsoft recommends this library.
https://dotnetfoundation.org/projects/mailkit

Related

"Invalid Authentication Headers" with IIS 10 and Windows Authentication

I have been struggling with getting Windows authentication to work on IIS10 for a .Net Core API. The error I am getting is 401.2:
You are not authorized to view this page due to invalid authentication headers.
I have made the following configurations:
Only windows authentication has been enabled on the site (Anonymous is disabled)
SPNs have been created for the site and the server has been enabled for delegation.
The application pool is configured to run under a domain account
Both cURL and Postman give me the same result. Interestingly, when I make use of the SwaggerUI on the API directly, I get the expected behavior, but when making external calls (from another server), I get the 401.2 error.
Some additional content from the error is that the Logon Method and Logon User is Not Yet Determined.
How do I resolve this issue?
I was under the assumption that Postman and cURL were sending the NTLM credentials/token as a part of the request by default, but was incorrect. I had to enable Failed Request Tracing on IIS and saw that they were trying to make use of anonymous authentication. Apparently Postman does not support NTLM authentication so I made use of cURL and appended the credentials. With this I could get the authentication to work with cURL.

the security token could not be authenticated when trying to authenticate to adfs 2.0

I'm trying to access a Microsoft Dynamics 2011 CRM deployment. My company has set up a ADFS test server for me and I am getting the following error. My client is written in react-native and uses Jason Lattimer's library which can be found here:
https://gist.github.com/jlattimer/bfeffb02d3efd159d0af
I believe the SOAP fault is being thrown by the getHeaderOnPremise function of his library.
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Actions:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:
Action><a:RelatesTo>urn:uuid:f1b5b2e8-b3bb-4c65-b533-
46dea29b5f66</a:RelatesTo></s:Header><s:Body><s:Fault><s:Code>
<s:Value>s:Sender</s:Value><s:Subcode><s:Value xmlns:a="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd">a:FailedAuthentication</s:Value></s:Subcode></s:Code><s:Reason>
<s:Text xml:lang="en-US">ID3242: The security token could not be authenticated
or authorized.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
I've googled everything I can regarding "The security token could not be authenticated or authorized" and am still stuck. Is it possible that because his library uses synchronous XMLHttpRequests, and I converted those to asynchronous, that this change causes this issue? Any ideas?

WARN:Authentication error: ntlm authorization challenge expected, but not found in Soap UI

I am trying to access WCF Webservice using Windows Authentication in Soap UI.
I am getting 401 unauthorized.
Following are the set up I done.
In Request Authorization Tab, I have given as NTLM
I have given username, password and Domain.
As well as WSS-Password Type: PasswordText or PasswordDigest, and Wss-TimeToLive: 2000
Tried for Basic and Kerberos as well. Getting 401 response ONLY..
Getting following in the http log.
WARN:Authentication error: ntlm authorization challenge expected, but not found
What needs to be done to solve this issue?
I am assuming you are connecting to a VPN in order to access the webservice, and that you have already verified the credentials are correct (ie: by accessing the endpoint in a browser). I will also assume your soapUI's ntlm configuration is correct.
If so, add -Djava.net.preferIPv4Stack=true to your .vmoptions file (under bin directory).

Encountered errors when trying to set up the OAuth 2.0 endpoint on my dynamic CRM 2015 internet facing deployment hosted on ADFS 3.0?

I am following the guidelines described in msdn website to set up the dynamic CRM server 2015 in my local domain, everything works as expected.
But I have some problems accessing my server with OAuth 2.0 authentication. From the official document, OAuth authentication is supported by dynamic CRM.
Developers who create modern and mobile apps, including apps not
built on the .NET Framework, can access Microsoft Dynamics CRM
business data through the SOAP and OData endpoints of the organization
web service. This web service supports certain authentication
capabilities found in the OAuth 2.0 protocol.
However when I am following the link to perform the OAuth flow, I get the below error message information in AD FS event log when trying to get the access token.
Encountered error during federation passive request. Exception
details: Microsoft.IdentityServer.RequestFailedException: MSIS7065:
There are no registered protocol handlers on path /adfs/oauth2/token
to process the incoming request. at
Microsoft.IdentityServer.Web.PassiveProtocolListener.OnGetContext(WrappedHttpListenerContext
context)
I've already added the OAuth 2.0 application into my CRM server. My question is which steps do I missed to make the OAuth authentication works?
Updated [11/11/2015]:
It turn out to me that there might be some configuration errors when I used postman do the token acquisition operation. I used PowerShell and it works. Shared my command below:
$nvc = New-Object System.Collections.Specialized.NameValueCollection
$nvc.Add("client_id", "you client id")
$nvc.Add("grant_type", "authorization_code")
$nvc.Add("code", "authorization code")
$nvc.Add("redirect_uri", "your redirect uri")
$wc = new-object net.webclient
$response = $wc.UploadValues("https://your.adfs.server/adfs/oauth2/token", "POST", $nvc)
$tokens = $wc.Encoding.GetString($response);
I had the same exact error while using postman. I just forgot to use x-www-form-urlencoded. Then it worked nicely.

Get 401 Unauthorized when call web api even if I enable Anonymous Authentication

I am developing a web api. When I ran web api in local workstation by Visual Studio and used Fiddler or IE to consume it, all things were fine.
But if I deployed it into a remote IIS server, I get 401 error code in IE, Fiddler or client application. Even I enable Anonymous Authentication in IIS, 401 still occurs.
Could anyone give me some suggestions?
Thanks.
You can right click in the Authentification the "Anonymous Authentification" and select Edit. From there, you can assign on which credential you run the Anonymous authentification. If you set your own account, it should work (or any account that can run the web api).