Mike Corcoran
Mike Corcoran

Reputation: 14564

Getting sender IP address from Exchange Server 2003 using WebDAV

I recently wrote an application for our company to process newsletter signup requests via signup emails sent to an inbox on our Exchange 2003 servers using WebDAV. This all works fine.

Now we've realized that for auditing purposes, we need to capture the ip address of where the signup request originated. My question is, is there a way to request the original ip address of the originator of the email with my WebDAV request?

I've browsed through the urn:schemas:mailheader: and the urn:schemas:httpmail: documentation and didn't see a field you can request with this data besides maybe urn:schemas:mailheader:path. But when I make a request to our exchange server with the path in the request, the status for that property comes back 404 not found.

It looks like http://schemas.microsoft.com/cdo/smtpenvelope has a clientipaddress property that would have this information, but that is only applicable to messages still in transit.

Has anyone had to do this before and figured out a way to snag the ip address of the user who originated the email? It probably isn't helpful to the question, but the format of my WebDAV request is below:

string webdav =
    @"
    <?xml version=""1.0""?>
    <D:searchrequest xmlns:D = ""DAV:"">
        <D:sql>
           SELECT 
                ""DAV:displayname"", 
                ""urn:schemas:httpmail:fromemail"",
                ""urn:schemas:mailheader:subject"", 
                ""urn:schemas:httpmail:textdescription"",
                ""urn:schemas:mailheader:date""
           FROM 
                SCOPE('shallow traversal of ""{0}""')  
           WHERE
                ""DAV:isfolder"" = false AND 
                ""urn:schemas:httpmail:read"" = false
        </D:sql>
    </D:searchrequest>                 
    ";

Upvotes: 0

Views: 313

Answers (1)

Steven V
Steven V

Reputation: 16595

This comes back to SMTP more than it comes to Exchange/WebDAV. It really depends on which email service the end user is using. SMTP can pass an email around multiple times before it ends up at the destination. Normally, each hop adds a Received: from header, with some additional information like an IP address.

But, some services, like Google, don't count the user sending the email has a hop, and the originating IP address is a Google SMTP server. So you'll never know the end user IP address from the email. Then, other services may count the end user's public IP address as the first hop. And some other services may add a special header like X-Sender-IP or X-Originating-IP to the message.

So, there isn't a guaranteed way to obtain that information. Part of it has to do with the distributed nature of SMTP, the prevalence of webmail and some privacy concerns. If this information is critical to your auditing, you may want to setup a simple webform which could send an email to this inbox, and then you could add additional information like an IP address to the body of the email.

Upvotes: 0

Related Questions