OfficeDev / ews-managed-api

Other
584 stars 317 forks source link

When will there be a DotNetCore version of this assembly so we can use it on Linux? #76

Open PaulDMendoza opened 8 years ago

PaulDMendoza commented 8 years ago

With .NET Core soon to be releasing, it probably makes sense to make a version of this for .NET core.

NattyNarwhal commented 8 years ago

It actually does compile, you just need to remove references to Active Directory (one or two exception catch blocks) and you're done.

ststeiger commented 6 years ago

It actually has more issues than that. 1) ActiveDirectory (you need to replace it for that it works correctly) 2) TimeZoneNames - they are different on Windows and Linux - the get written in the XML-webservice-exchange-file, so you get a HTTP 500. 3) NTLM with double header (negotiate, ntlm) doesn't work on Linux - bug in .NET Framework/CURL. 4) Some other minor fixes, that it compiles.

I ported it (everything short of issue 1 - therefore must manually set the service-url). I have it working on Linux, here, with .NET Core 2.0.

LoungeFlyZ commented 6 years ago

@ststeiger it would be great if you could submit a PR to this repo that others could take a look at/use!

ststeiger commented 6 years ago

Well, I've done more than that, I've reorganized the project into a solution with several projects, so I can't just issue a pull-request from the source here.

But a lot has changed - ActiveDirectory-support is now there, so it doesn't need to be replaced. .NET 2.1 should have fixed NTLM, though didn't test if it did. The NTLM-fix should really be fixed in .NET-Core runtime, and not here. The only thing that needs to be fixed right now is TimeZoneNames, and commenting out WebException.

I can however clone the project, fix the timezone problem, and issue a pull-request. Somebody would then need to take a look at making the timezone-conversion faster - I'm too lazy for that ;) I don't know if they want to pull such a thing in the first place.

Also, it would be nice to put all the source-code into a shared-project, and make a .NET Framework x, .NET Core 2,2.1, and NetStandard library project.

viktdm commented 6 years ago

@ststeiger Thank you for your efforts to make the EWS Managed API library compatible with .Net Core. I've been playing with your version and it does work ok on Linux. However, it has the same problem that I encountered with Sherlock's fork: https://github.com/sherlock1982/ews-managed-api/issues/28#issue-344743139. It seems to me that some major changes are required in order to support .Net Core 2.1.

ststeiger commented 6 years ago

@viktdm: What exactly doesn't work ? I've tested it on Linux and it works just fine...

viktdm commented 6 years ago

@ststeiger: It works, but creates too many connections.

ststeiger commented 6 years ago

And that is not so on Windows ?

viktdm commented 6 years ago

@ststeiger: The problem with network connections manifests on both Windows and Linux. So far it seems that the problem can be solved only by changing a few core classes in the EWS Managed API library and implementing the client-server communication logic based on new HttpClient class (with or without HttpClientFactory) instead of old HttpWebRequest and HttpWebResponse ones.

LoungeFlyZ commented 6 years ago

@ststeiger nicely done! a new community fork of this repo with your changes + others from the community would be pretty sweet if you were ok with doing that? I made a PR to this repo a while back and it finally got merged, but now i dont think there will be any/many more accepted.

ststeiger commented 6 years ago

@viktdm: So it is not a bug per se then. I think that sounds very familiar - it sounds like basic authentication. The spec of basic-authentication actually says you first need to establish a http-connection, upon which you get access denied, upon which you should do a https request. It's moronic IMHO, but if that's what the spec says, then that's what you need to implement. I think you can disable this "feature" with the pre-authenticate property, i think on the main-service, if I remember right.

@LoungeFlyZ: Yes, as they write

Starting July 19th 2018, Exchange Web Services (EWS) will no longer receive feature updates.

I've forked the repository at https://github.com/OfficeDevUnofficial/ews-managed-api and will merge my changes either today or tomorrow, and update the readme accordingly. Will keep you posted.

You want write access ?

viktdm commented 6 years ago

@ststeiger: It has nothing to do with the authentication. It is the bug (or feature?) in .Net Core 2.1: https://github.com/dotnet/corefx/issues/26373. All applications or libraries (including EWS Managed API) using old HttpWebRequest class are affected. So far it looks that Microsoft is not going to fix HttpWebRequest class and recommends to use HttpClient class: https://github.com/dotnet/platform-compat/blob/master/docs/DE0003.md.

ststeiger commented 6 years ago

@viktdm: Well, in that code it actually makes 1'000 requests, so that sounds like normal. The better question is why do you need to make 1'000 requests, instead of issuing one request with 1000 post parameters... Sound to me like bad API design - and well yes - unfortunately that sounds like Outlook/Exchange. But sure, we can replace HttpWebRequest with HttpClient. Feel free to send a pull request as soon as everything is uploaded.

ststeiger commented 6 years ago

@viktdm, @LoungeFlyZ, @ALL

There is now a NetStandard 2.0 version with my fixes at https://github.com/OfficeDevUnofficial/ews-managed-api

If you run it on .NET-Core 2.0 on Linux, you need to set the titanium proxy to remove the negotiate header. In .NET Core 2.1, this should be fixed, and therefore superfluous, but I don't have 2.1 installed, so I can't check.

I've added this class in a fixed version of Titanium.WebProxy https://github.com/OfficeDevUnofficial/ews-managed-api/blob/master/Titanium.Web.Proxy/__OMG/ProxyTestController.cs

Usage is as you see here: https://github.com/OfficeDevUnofficial/ews-managed-api/blob/master/Titanium.Web.Proxy/__OMG/Program.cs

The actual fixes are in https://github.com/OfficeDevUnofficial/ews-managed-api/tree/master/ews-managed-api/TimeZoneData and are in need of being cleaned up.

Please apply any fixes to ews-managed-api first, later the shared project can be cloned into a new shared project where we can add HttpClient for Net35+.

async could potentially be done for Net40 as well (surprise surprise, async/Task compiles in .NET 4.0).

usselite commented 7 months ago

@ststeiger I was wondering, can you confirm if the NTLM issue was resolved with later .NET releases or is the titanium proxy still needed? Having issues with NTLM at the moment.