1
votes

I'm working on a web application to access exchange server 2010 to get emails from the server. The question is, we don't have domain name for this server. What I know is it's IP address. Is that possible to use Exchange Web Service to access the server? This is my code:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010); service.Credentials=new NetworkCredential("StevenZack","123456","208.243.49.20"); //service.AutodiscoverUrl("[email protected]"); service.Url = new Uri("https://208.243.49.20/EWS/Exchange.asmx"); FindItemsResults findResults = service.FindItems( WellKnownFolderName.Inbox, new ItemView(10));

    foreach (Item item in findResults.Items)
    {
        div_email.InnerHtml = item.Subject + "<br />";
    }

It comes out with an error of "The remote certificate is invalid according to the validation procedure"

How to deal with this situation? Any idea? Thank you for your time!

1
Since you're using SSL (i.e., HTTPS), the server must have a certificate. What domain/IP is this certificate issued to?Aasmund Eldhuset
No domain right now, IP is 208.243.49.20Steven Zack
Is that also what the server certificate is issued to?Aasmund Eldhuset
It is now using a self-signed certificateSteven Zack
I'm asking what the certificate is issued to (the CN field of the certificate), not who it is issued by. :-) Anyways, since it is self-signed, you might need to add the certificate to Trusted People on the machine that is trying to connect to the service.Aasmund Eldhuset

1 Answers

1
votes

The SSL warning can be avoiding by setting the ServicePointManager.ServerCertificateValidationCallback delegate (see http://www.infinitec.de/post/2008/11/26/ExchangeWebServices-WebDAV-and-untrusted-server-certificates.aspx).

But this probably won't help you. If you specify 208.243.49.20 you are connecting to the machine using a machine-local account instead of your domain account.

Can you, by any chance, use integrated authentication? You could just impersonate the user and use his credential directly. This way, the user doesn't have to enter his credentials again. Note that you would need to configure Kerberos if your web application resides on a different server as your Exchange server.