Nothing showed when browsing ews Exchange.asmx - c#

Since yesterday, I tried to use the exchange web service but it was not able. Firstly when I was trying to access to the web service by the browser and the test program using Microsoft.Exchange.WebServices, there was an error 403 forbidden. But this issue I solved by unchecking require SSL option in IIS. And now the problem is when I try to access on the ews using my program, I encounter 401 unauthorized error, and if I try to browse the web service on the browser, only an empty page is returned (even when I browse the wsdl).
I tried to change the role and the password but it was not working.
Please help me to find out what I am missing.
Here is my test program code:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials(username, password, domain);
service.Url =new Uri("server/EWS/Exchange.asmx");
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OnValidationCallback);
ExpandGroupResults groupResults = service.ExpandGroup(emailAddress);
The exception is on the last line

I found why the XML for the ews was not showing. It was because the IIS was not installed with basic authentication and Windows authentication. After installing those two authentication method, the web service shows its xml.
This is the link I referred: https://migrationwiz.zendesk.com/entries/506613-how-do-i-verify-ews-is-setup-properly

Related

401 Unauthorized exception throws on Sharepoint Webpart using DataContext

I'm using the below code to create a new instance of Sharepoint datacontext:
spDataContext con = new spDataContext(new Uri("http://mysite/subsite/_vti_bin/ListData.svc"));
con.Credentials = CredentialCache.DefaultCredentials;
Then I try fetching the items by using
var result = con.testingList.ToList();
Then Below error shows:
"401 UNAUTHORIZED"
Here's the screenshot of the error:
But if I change the credentials by providing the sharepoint admin username and password, I am able to fetch the items.
con.Credentials = new NetworkCredential(username, password);
But the problem is: I want to use the current user's credentials instead of administrator account, since not all the items are supposed to be seen by current user.
Some addition information from the IIS:
At first, all authentication methods are enabled, then I tried turning off basic and digest authentication to see if it helps, but the exception still throws.
So how to fix this problem??
Check what account you are actually connecting with by inspecting a breakpoint, writing to a log or checking the server's audit trail/Logs (IIS/SharePoint) - are you sure it's a valid account and not an IUSR_xyz IIS account or something like that? Also check that you are not hitting a Kerberos "double hop" if you are working with a distributed architecture. This can often trip you up when adding another server/service to the mix.
In order to get this to work, you should configure the Authentication options in IIS as follows:
Anonymous Authentication - DISABLED
ASPNET Impersonation - DISABLED
Windows Authentication - ENABLED
You can use the CredentialCache.DefaultCredentials, but I would suggest switching from using the WCF services to using CSOM (Microsoft.SharePoint.Client).
At last the reason was:
I don't have the System.Web assembly in the class library, so the system was unable to get the CredentialCache.DefaultCredentials.

SPErrorInfo - The app <appid> does not have an endpoint or its endpoint is not valid

I have created a SharePoint Provider Hosted app using ASP.NET webforms. I am attempting to access a list within the SharePoint site that the app is installed on. When I attempt to get the clientContext:
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clientContext = spContext.CreateAppOnlyClientContextForSPHost())
{
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();
ListCollection listOfLists = web.Lists;
clientContext.Load<ListCollection>(listOfLists);
clientContext.ExecuteQuery();
}
I receive a 401 not authorized error on the clientContext.ExecuteQuery() line.
When I inspect the appredirect.aspx call in Fiddler, I have no SPAppToken, and SPErrorInfo says The app <appid> does not have an endpoint or its endpoint is not valid.
I have not been able to locate any information about this error message, or where to set/check the endpoint, or even what endpoint it is referring to. How do I begin to troubleshoot this problem?
You probably need to enable Windows Authentication, disabling Anonymous authentication, for the provider hosted app.

403 when connecting to Exchange Online

I am trying to use EWS on an Office 365 account however I get a return of (403 Forbidden)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.Credentials = new WebCredentials("mv003237", "correctpw","domain");
service.AutodiscoverUrl("mv003237#domain.co.uk");
To login and view the Webservices file on outlook.com/EWS/Exchange.asmx I need to authenticate with mv003237#live.domain.co.uk
I have tried several combinations of this and still get the same error message.
Has anyone had a similar experience of connecting to an office 365 account before?
My WINDOWS login for this account does have a domain of RDG-HOME but I haven't seen a domain for login into OWA.
Many thanks in advance
If you've already removed the domain name (as Matt suggested in his comment) the one thing that remains is to automatically follow redirects in the autodiscover process.
Change your last line to
service.AutodiscoverUrl("mv003237#domain.co.uk", redirect => true);
to follow the redirection response that Exchange Online sends.
So the complete sequence then becomes:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.Credentials = new WebCredentials("mv003237", "correctpw");
service.AutodiscoverUrl("mv003237#domain.co.uk", redirect => true);
Cannot comment due to low reputation score and hence responding as an answer.
Are you able to login into OWA with "mv003237#domain.co.uk"? If yes, have you tried by hardcoding Url instead of using Autodiscover to understand if issue is with Autodiscover or EWS. Try following instead of autodiscover call:
service.Url = new Uri(#"https://outlook.office365.com/ews/exchange.asmx");
If above works fine, subscribe to RedirectionUrlValidationCallback with AutodiscoverService and see which redirected URL is throwing 403. Or enable verbose logging with Trace* properties present on service object.

401 unathorised when using windows authentication to access web services

I have a asp.net mvc 4.0 web application that attempts to use windows authentication to authenticate against some web services. its hosted in iis7
The web services are autodesk vault 2011 web services, I present the user with a login screen where they can use a vault user account or they can use their windows login. There is no issue with using a vault account it logs in via the vault web services and call the various vault web services such as pulling data out of the vault. no issues here
When trying to log in using windows authentication then I get a 401 error when accessing the web services
I think that it could be a double hop issue so the server admins are going to enable Kerberos so we can at least eliminate this as a possibility. In the live environment the site and web services are located on different servers.
However for testing I have a virtual machine setup and the site and web services are on the same machine and I still get a 401 issue so maybe it is an iis configuration issue and not a double hop issue as originally thought
I have tried the following but with no success
I have added the following code to the winauthservice (I have wrapped the web services so that I can override the invoke and I have created a factory class to instantiate the services)
this.UnsafeAuthenticatedConnectionSharing = true;
var credentialCache = new CredentialCache();
credentialCache.Add(new Uri(this.Url), "NTLM", new NetworkCredential(identity.Name, identity.Password.ConvertToUNSecureString(), identity.Name.Substring(0, identity.Name.IndexOf("\\", StringComparison.OrdinalIgnoreCase))));
this.Credentials = credentialCache;
I have also tried it with Negotiate instead of NTLM
I have disabled the loopback check in the registry and I have added the server name and localhost to the BackConnectionHostNames registry entry
I have disabled anonymous authentication for the web site in iis and enabled windows authentication. In the providers for windows authentication I have removed negotiate and just left NTLM as saw a post recommending to do this.
In the web.config I have set authentication mode = windows
I have the following in my IIS logs
2013-09-25 09:11:05 fe80::9565:6102:fe2d:8f41%10 POST /AutodeskDM/Services/WinAuth/WinAuthService.asmx - 80 - fe80::9565:6102:fe2d:8f41%10 Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+4.0.30319.296) 401 2 5 11572
2013-09-25 09:11:05 fe80::9565:6102:fe2d:8f41%10 POST /AutodeskDM/Services/WinAuth/WinAuthService.asmx - 80 - fe80::9565:6102:fe2d:8f41%10 Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+4.0.30319.296) 401 1 3221225581 10
I'm running out of ideas as to what the issue could now be, but my thought is if I can get this working in my test vm then I may have more luck in the live environment
I had problems with authentication surviving a redirect when using a HttpWebRequest object, but I'm not sure if this is your problem. I noticed the redirect and the missing authentication using Fiddler2.
What I had to do was to set PreAuthenticate = true on the HttpWebRequest object
HttpWebRequest request;
request = (HttpWebRequest)WebRequest.Create(uri);
request.PreAuthenticate = true;
request.Credentials = new CredentialCache {{uri, "Basic", credentials}};
But, like I said, I'm not sure if this applies in your situation though.

Proxy Authentication Error while calling FedEx webservice

I am trying to call the FedEx tracking webservice. Currently I am running the sample application provided by FedEx itself (Added my test account number and other details). When I run the application, I get the following error:
The remote server returned an error: (407) Proxy Authentication Required.
I am inside a proxy at my organization and I tried provided the proxy server details to the webservice client using the WebProxy class as:
trackService.Proxy = WebProxy.GetDefaultProxy();
and also by providing the proxy server details as:
trackService.Proxy = new WebProxy("IP",8080);
But I still keep getting the same error!! Could somebody help me how to resolve this problem?
Thanks in advance,
Regards,
Abdel Olakara
What you seem to be missing is the proxy credentials. Try this:
trackService.Proxy = new WebProxy("IP", 8080);
trackService.Proxy.Credentials = new NetworkCredential(
username, password, domain);

Categories

Resources