Aarrgghh!!

Exchange Item Creator

Explanation

My workplace has a heavy investment in Microsoft Exchange. We also have a very heavy investment in ColdFusion. So, we've tried to set the two up on a blind date for years. This past year, we finally started to see sparks. It turns out that Exchange can be accessed with WebDav for the purpose of creating Exchange Items. With a little work, ColdFusion can communicate using WebDav. With a little more work, ColdFusion can create Exchange Objects.

The CFC below will allow developers to create contacts and appointments on a remote Exchange server. This CFC is not intended to be an exhaustive run down of what you can do. There are well over a hundred attributes that you can fool with in an Exchance object. If you need to handle properties other than we take on in this CFC, you can find a longer list of them at these following locations.

The "we" of which I have been referring are two fellow Wharton Computing Employees and myself.

  • Jason Lehman did the hard work of figuring out how to create WebDav requests and post them to an Exchange server. He also did the initial work in creating appointments in Exchange.
  • I wrote the contact creation function, and figured out how to do a socket connection in ColdFusion.
  • Dave Konopka tested and refined the contact creation routine.

Using the code below we have done the following:

  • Created an online facebook/directory that synchs user contact info directly to subscribers Exchange mailboxes (and by extention with wireless contact synching, their phones).
  • Augmented calendar to push classes and special events to student's Exchange Calendar without client download.
  • Sent my boss on a wild goose chase with phantom appointments.

What Does It Actually Do?

  • It takes input about the Exchange item.
  • If the home server of the desired mailbox is not entered, it looks it up using LDAP.
  • It turns all the information into a WebDav formatted XML packet
  • It uses a secure HTTP socket connection to performa a HTTP PROPPATCH operation to the Exchange Server.
  • Exchange adds the item to the desired mailbox.

Requirements

  • Exchange 2003 with SSL on HTTPS enabled.
  • Active Directory which is a prerequisite of Exchange, so no worries.
  • ColdFusion MX 7
  • Access to LDAP port on Active Directory Domain Controller
  • Access to HTTPS port on Exchange Server [1]
  • A domain account that is a member of "Exchange Mailbox Admins" [2]

[1]I imagine that you don't need HTTPS to do it, but my exchange administrators insisted, so there you go.

[2]Or the username and password of the user of the mailbox you are trying to modify. But as coded this cfc doesn't allow that which is why I'm making the soruce avaialable.

Installing and Using

  1. Download the source below.
  2. Set the variables in the Init method.
    exchange_user:The Active Directory account with "Exchange Mailbox Admins" privs.
    exchange_password:The password for that account
    domaincontroller:The dns hostname of an Active Directory Domain Controller against which to make ldap calls.
    ldaproot:The ldap serach root of the Active directory domain.
    cflogname:An arbitrary name for the CFlog to use to track this stuff.
  3. Copy somewhere on your server.
  4. Create an appointment in your boss's mailbox that sends him to a client location in the next 20 minutes.
  5. Watch him or her run out.
  6. Take the rest of the day off.

Sample Code

Here's a sample contact creation.

		


1: <cfinvoke component="Exchange" method="CreateUpdateExchangeContact" returnvariable="CreateUpdateExchangeContactRet">
2: 	<cfinvokeargument name="exchangeUsername" value="[username]"/>
3: 	<cfinvokeargument name="FirstName" value="Earl" />
4: 	<cfinvokeargument name="LastName" value="Ragefest" />
5: 	<cfinvokeargument name="OfficeNumber" value="(215) 555-1234" />
6: 	<cfinvokeargument name="PrimaryEmail" value="earl.ragefest@gmail.com" />
7: 	<cfinvokeargument name="guid" value="D5DB7AE5-AA76-B59B-B0C1AC6E528E6FE3" />
8: </cfinvoke>


The cool thing about keeping track of Guid's is that they allow us to update the contact, so that if it turns out that Earl is not his real name, we can update the contact we created.

		


1: <cfinvoke component="Exchange" method="CreateUpdateExchangeContact" returnvariable="CreateUpdateExchangeContactRet">
2: 	<cfinvokeargument name="exchangeUsername" value="[username]"/>
3: 	<cfinvokeargument name="FirstName" value="Steven" />
4: 	<cfinvokeargument name="LastName" value="Ragefest III" />
5: 	<cfinvokeargument name="OfficeNumber" value="(215) 555-1234" />
6: 	<cfinvokeargument name="PrimaryEmail" value="earl.ragefest@gmail.com" />
7: 	<cfinvokeargument name="guid" value="D5DB7AE5-AA76-B59B-B0C1AC6E528E6FE3" />
8: </cfinvoke>


Now for Appointments, here's an easy, if unlikely, example.

		


1: <cfinvoke component="Exchange" method="CreateUpdateExchangeAppointment" returnvariable="CreateUpdateExchangeAppointmentRet">
2: 	<cfinvokeargument name="exchangeUsername" value="[username]"/>
3: 	<cfinvokeargument name="Subject" value="Lunch w/ Ben Forta"/>
4: 	<cfinvokeargument name="Location" value="Las Vegas - Maxx 2006"/>
5: 	<cfinvokeargument name="StartTime" value="12:00PM 10/24/2006"/>
6: 	<cfinvokeargument name="EndTime" value="2:00PM 10/24/2006"/>
7: </cfinvoke>


Code

exchange.cfc

Documentation

Exchange.cfc Documentation