I am new to using php for querying exchange server. I downloaded the class_http.php and class_xml.php. I am trying to run the example "Grab all properties for an item " given at http://www.troywolf.com/articles/php/exchange_webdav_examples.php#allprops . I have modified the following variables in the example php script (exch3.php):

$exchange_server = "http://mail.msm.edu";
$exchange_username = "dkaur@msm.edu";
$exchange_password = "mypswd";

I have also configured apache to run ssl by creating a self signed certificate and encryption key.

When I run this file on https://localhost:24343/i2b2/exch3.php

I get the following output. Please suggest what am I doing wrong. Any help is highly appreciated.

"
stdClass Object
(
    [HTML] => Array
        (
            [0] => stdClass Object
                (
                    [HEAD] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [TITLE] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [_text] => Error
                                                )

                                        )

                                )

                        )

                    [BODY] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [HEAD] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [TITLE] => Array
                                                        (
                                                            [0] => stdClass Object
                                                                (
                                                                    [_text] => Secure Channel Required
                                                                )

                                                        )

                                                )

                                        )

                                    [BODY] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [H1] => Array
                                                        (
                                                            [0] => stdClass Object
                                                                (
                                                                    [_text] => Secure Channel Required
                                                                )

                                                        )

                                                    [_text] => This Virtual Directory requires a browser that supports the configured encryption options.
                                                )

                                        )

                                )

                        )

                )

        )

)

"

My target is to query if a user is a valid user on exchange server, and get his name email id etc from exchange server.

Thanks,

Dkv.

Recommended Answers

All 6 Replies

Is the exchange server on your localhost?
If it isn't then there was no need to configure apache accept ssl.

What I think is happening is the exchange server you're testing on requires SSL and your classes do not support SSL or your PHP build does not support SSL.

Is the exchange server on your localhost?
If it isn't then there was no need to configure apache accept ssl.

What I think is happening is the exchange server you're testing on requires SSL and your classes do not support SSL or your PHP build does not support SSL.

Sorry, I don't think that was very clear.

You don't need Apache to accept SSL since you're not making the SSL connection to Apache. The SSL connection is between your PHP script and the Exchange Server.
You'll need your PHP script to talk SSL to the exchange server.

Is the exchange server on your localhost?
If it isn't then there was no need to configure apache accept ssl.

What I think is happening is the exchange server you're testing on requires SSL and your classes do not support SSL or your PHP build does not support SSL.

Thank you for the reply. Do you mean i need to configure php.ini to support ssl? if yes, please tell how to do it. I am new to php. I appreciate your help.

Thanks

Dkv

I have configured my php.ini to support ssl. the following lines have been uncommenred:
extension=php_openssl.dll
extension=php_ldap.dll

the classes that I am using are class_http.php and class_xml.php from troy@troywolf.com and they seem to support ssl.

I still get this error
"
There is a problem with the http request!
New http() object instantiated.
--------------------------------
fetch() called
url: https://webmail.msm.edu/public/Email%20Log/Some%20Message-668992879.EML
getFromUrl() called
Could not open connection. Error 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
"

I tried this with
$exchange_server = "mail.msm.edu";
$exchange_server = "http://mail.msm.edu";
$exchange_server = "https://mail.msm.edu";

nothing works.

Please help.

Thanks,

Dkv

The error you're having seems to be the default in PHP when a socket connection attempt times out.

I'd like to suggest anotehr way of going about this:

Test out a socket connection you're trying to make with telnet before trying it with PHP.

I'm not familiar with the socket protocol exchange servers use. I thought they used plain old POP3 and SMTP but it seems the class you're using is trying to make a request for XML over HTTP?

Anway, whatever protocol is being used, try to take a look at the protocol specifications, or just a tutorial on how to test a service using that protocol with telnet to get a basic idea of whats happening on the network level.

That way, you can know what to expect when it comes to coding it with PHP. Using the library may make it more complicated then it is, unless you're already familiar with the protocol.

Basically, once you can telnet into the service, then doing the samewith PHP would be simple.

Here's an example of a simple HTTP Request with telnet:

telnet example.com 80
<enter>
GET /index.html HTTP/1.1
<enter>
HOST: example.com
<enter>
<enter>

The server at example.com with respond with the HTTP resource.

doing that with PHP:

<?php

$fp = fsockopen('example.com', 80);
fwrite($fp, 'GET /index.html HTTP/1.1');
fwrite("\n");
fwrite($fp, 'HOST: example.com');
fwrite("\n");
fwrite("\n");

while($response = fread($fp, 2082)) echo $response;

fclose($fp);

?>

Once you have your simple tests complete, it would then be easier to use the library since you know the service is not the problem...

If the service is HTTP, the shortcut would be to just use:

echo file_get_content($url);

where $url is teh url of what you want. Then examine the response..

Thank you for your reply. I actually solved my problem another way. I queried the active directory using LDAP search methods in php.

Thanks,

Dkv

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.