jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 305 forks source link

Request always returns null #11

Closed jamesiarmes closed 12 years ago

jamesiarmes commented 12 years ago

Really impressed with this project. Great work. I've got it working on my dev server (WAMP stack)...but when I move it to my production (LAMP) Debian server I get nothing but a NULL result for any of the function calls. I might be missing something basic...I'm sure it's a configuration issue on my end...some kind of error would be helpful....any ideas on where I could start with troubleshooting??? Do I need to COM objects enabled, etc..? Any more info on the dependencies would be really great.

Originally posted by kvnlnt@yahoo.com on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11

jamesiarmes commented 12 years ago

You are probably missing either cURL or SOAP for PHP

Originally posted by torbenkoehn on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c1

jamesiarmes commented 12 years ago

I have both cURL and SOAP for PHP but always get a null as well

Originally posted by frak.off on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c2

jamesiarmes commented 12 years ago

The problem is that you are likely receiving a 401 Unauthorized response back php-ews is not handling that properly. It appears that the options that cURL is compiled with in Debian (as well as Ubuntu and probably other Debian based distros) has changed. I'm going to try to compile from source and see if I can get it working.

Originally posted by jamesiarmes on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c3

jamesiarmes commented 12 years ago

Having done some investigation since your post, it does indeed seem that the account I was using did not have the correct permissions to access everyone's mailbox. Sorry for the misleading post.

Originally posted by frak.off on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c4

jamesiarmes commented 12 years ago

In order to fix the issue with the version of cURL currently provided in Debian in Ubuntu, you will need to compile from source using the following to configure (you may have to provide additional options if you have other requirements):

./configure --enable-http --enable-ftp --enable-file --enable-telnet --enable-tftp --enable-ipv6 --enable-crypto-auth --enable-tls-srp --enable-cookies

This has been tested with cURL 7.22 on Ubuntu 10.04 (Lucid Lynx).

Originally posted by jamesiarmes on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c6

jamesiarmes commented 12 years ago

Marking this as "WontFix" since it is not actually an issue with the library.

Originally posted by jamesiarmes on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c7

jamesiarmes commented 12 years ago

To verify that your curl setup is working you can run the following from the command line (make sure you replace host, username and password with the appropriate values):

curl https://*host*/EWS/Exchange.asmx -w %{http_code} --ntlm -u *username*:*password* -k

If curl is configured correctly, this should return a 302 rather than a 401.

Originally posted by jamesiarmes on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c8

jamesiarmes commented 12 years ago

ok, i'm on unbuntu 10.04 if installed the build-dep's for curl with apt-get build-dep curl downloaded the sources wget http://curl.haxx.se/download/curl-7.23.1.tar.gz extracted them and configured with your line

i get:

checking whether to enable the threaded resolver... no checking whether to enable verbose strings... yes checking whether to enable SSPI support (Windows native builds only)... no checking whether to enable cryptographic authentication methods... yes checking whether to enable NTLM delegation to winbind's helper... yes checking whether to enable TLS-SRP authentication... yes checking whether to enable support for cookies... yes checking whether to enable hidden symbols in the library... no

but then i get:

curl version: 7.23.1 Host setup: x86_64-unknown-linux-gnu Install prefix: /usr/local Compiler: gcc SSL support: enabled (OpenSSL) SSH support: no (--with-libssh2) zlib support: enabled krb4 support: no (--with-krb4*) GSSAPI support: enabled (MIT/Heimdal) SPNEGO support: no (--with-spnego) TLS-SRP support: no (--enable-tls-srp) resolver: default (--enable-ares / --enable-threaded-resolver) ipv6 support: enabled IDN support: enabled Build libcurl: Shared=yes, Static=yes Built-in manual: enabled Verbose errors: enabled (--disable-verbose) SSPI support: no (--enable-sspi) ca cert bundle: /etc/ssl/certs/ca-certificates.crt ca cert path: no LDAP support: enabled (OpenLDAP) LDAPS support: enabled RTSP support: enabled RTMP support: no (--with-librtmp) Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMTP SMTPS TELNET TFTP

so it will compile without TLS-SRP, google told me that openssl hasn't tls-srp support... is it needed?

if i compile it anyway i still get the the 401 error

what have you done?

Originally posted by mr.schickfick on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c9

jamesiarmes commented 12 years ago

@mr.schickfick are you still having trouble with this? I have not tested this method using cURL 7.23.1. You can get cURL 7.22.0 (which is what I used above) from http://curl.haxx.se/download/curl-7.22.0.tar.gz.

Originally posted by jamesiarmes on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c10

jamesiarmes commented 12 years ago

hey, i have exactly the same problem, the code in #8 returned 401

Originally posted by icksde1 on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c11

jamesiarmes commented 12 years ago

same as #11. If we're getting a 401 return to

curl https://*host*/EWS/Exchange.asmx -w %{http_code} --ntlm -u *username*:*password* -k

but can use those same credentials to log into https://_host_/owa without a problem, where should we look next?

Originally posted by Zxurian on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c12

jamesiarmes commented 12 years ago

Any help on this? I have 2 CentOS servers. It works on one but not the other. I don't see much of a difference. Maybe a different in curl versions?

Originally posted by keith@keithslater.com on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c13

jamesiarmes commented 12 years ago

From what I can tell it is definitely a problem with what curl version is being used. It looks like somewhere between 7.15.5 and 7.19.7 curl started using NSS for SSL instead of OpenSSL. From what it looks like curl 7.20.1 or above should fix the problem however I'm having a hard time upgrading.

Relevant info: https://bugzilla.redhat.com/show_bug.cgi?id=603783

Originally posted by keith@keithslater.com on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c14

jamesiarmes commented 12 years ago

Hi,

yes still issues, again with 7.22.0 same error:

curl-7.22.0# ./configure --enable-http --enable-ftp --enable-file --enable-telnet --enable-tftp --enable-ipv6 --enable-crypto-auth --enable-tls-srp --enable-cookies | grep -i SRP checking for SRP_Calc_client_key in -lcrypto... no checking whether to enable TLS-SRP authentication... yes TLS-SRP support: no (--enable-tls-srp)

Originally posted by mr.schickfick on Google Code: http://code.google.com/p/php-ews/issues/detail?id=11#c16

celevra commented 12 years ago

after a little bit of trying it seems like TLS-SRP is not required, but configure and installing with --prefix=/usr/ does the trick ;-)

jamesiarmes commented 12 years ago

More details on the issue with Ubuntu and another possible solution https://bugs.launchpad.net/ubuntu/+source/curl/+bug/675974

kelljery commented 12 years ago

Hi, I solved this issue on my Qnap webserver with the following

in line 77 of NTLMSoapClient.php, I comment the line (//) : // curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);

Kelljery

keithslater commented 12 years ago

Kelljery, I tried your solution and am still having the problem. Commented out:

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);

kelljery commented 12 years ago

Hi, I don't know why but it works only for a while... very strange and sorry for the bad news. On my qnap nas the php server is an old version. I asked to qnap they tell me they will update php with a new version on next firmware release which will come in april 2012 so I'm waiting for this hoping it will solve this problem. I tested this script without modification on a synology nas and it works without errors... Kelljery

kcaporaso commented 11 years ago

For Mac OS X users, if you use Mac Ports version 7.28.1 then problems with the NTLM 401 are resolved. Versions: OS X 10.7, PHP 5.4.6, libcurl 7.28.1