Index of /code/ruby-ews

Icon  Name                      Last modified      Size  Description
[DIR] Parent Directory - [   ] default.rb 23-Sep-2009 11:15 376K [   ] defaultDriver.rb 23-Sep-2009 11:15 40K [   ] defaultMappingRegistry.rb 23-Sep-2009 11:15 534K [TXT] ews.rb 23-Sep-2009 11:33 2.5K [TXT] ewslookup.rb 23-Sep-2009 11:15 2.2K
In this directory is some sample code I wrote for accessing a Microsoft Exchange Server via Exchange Web Services from ruby.

Motivation

I use mutt as my email client at work. It's fast and I like it. While I'm on the VPN, I can perform lookups just fine using the LDAP server on our AD servers.

However my problem cropped up while I was flying back from Michigan on Airtran using the in-flight wireless. I was checking and sending email but the connection kept dropping and my VPN connection kept dying.

We don't have LDAP exposed to the internet so I couldn't just stay off the VPN since I needed to lookup addresses. That's where this comes in.

I needed to be able to perform lookups for email addresses while not on the VPN.

Required gems:

Files:

Usage:

If you want to use the sample script, feel free. Edit the username,password and endpoint variables at the top. Results are returned as an Array with an Array for each result/member.

GAL Lookup

./ews.rb -g go
will perform a lookup against the GAL and return and Contact, Mailbox or Distribution List that matches.

Example Output:

[["Bob Gold", "bgold@mydomain.com", "Mailbox"],
 ["googleusers", "googleusers@mydomain.com", "PublicDL"],
 ["Golden Ticket Foods", "orders@externaldomain.com", "Contact"]]

DL Expansion

./ews.rb -l googleusers@mydomain.com
./ews.rb -l googleusers
Will return a list of members in that Distribution List. The EWS call for distribution lists behaves differently than the lookup call. You MUST type the exact name or SMTP address associated with the DL.

Example Output:

[["Jack Smith", "jsmith@mydomain.com"],
 ["Bob Gold", "bgold@mydomain.com"],
 ["Frank White", "fwhite@mydomain.com"]]

Gotchas:

The ExpandDL call to EWS requires the exact email address or name of the distribution list to get results. That's how MS did it. I plan on fixing it in another little version to do the following (in case you want to do it yourself):
    if no results are found for the expandDL call:
        perform a resolveNames call for the lookup passed and get any PublicDL results that match
        redo the expandDL call with the proper name/email address
    else "No results found" for real this time

Future

I'll probably write a few more classes to ineract with things like calendars and public folders allthough I honestly don't use them much.