This is a follow-up to my previous message of connecting ColdFusion to
Exchange.
Let's start with some history. Please keep note of the software
versions as they change in this story. The versions make a large impact
of using CF with Exchange.
About two years ago, we were still running MS Exchange (MSX) 5.5 and
CF5. After I realized the "link" between CF's service account and the
"user mailbox permission" in MSX, I was finally able to get the two
systems connected. I only had to install MSX's OWA 5.5 on my CF server
and point to one of our MSX servers to make the final connection.
That was fine.
Last summer, I upgraded to CFMX from CF5. A bit after that time, we
also upgraded our MSX servers from 5.5 to 2000. I was still able to
connect to MSX 2000 from CFMX because, at that point in time, I already
had OWA configured to connect to Exchange 5.5. Again, keep track of the
timeline of upgrades.
Now, we move to present day. I'm in the process of rebuilding my
CF/intranet servers this summer. I built a scratch server to make sure
things will go well with the lastest, released update of CFMX. I also
want to "clean up" the install process leaving out many steps I did in
the past that are not needed anymore.
This is where it gets bad. I attempted to install OWA 5.5 on the
scratch server and connect to MSX 2000. The OWA install fails each and
every time. My system admin and I can only think that OWA 5.5 currently
connects to MSX 2000 because it was already a working system BEFORE the
MSX 5.5 to 2000 upgrade. Now that I try to build a "fresh" server, MSX
2000 won't let me create a "new" connection from OWA 5.5. This also
means I have to either install the lastest release of CFMX on my current
server setup and can NEVER completely wipe and refresh the server (due
to the Exchange version issues) or I have to redo how my web site
connects to Exchange.
I chose to wipe the server and figure out a new solution. I don't want
to get into the situation where my CF server can't grow with me.
To sum up the issues above...
* If you are on MSX 5.5 and CF5/CFMX (with OWA 5.5 on the same server),
you should be OK.
* If you then upgrade MSX from 5.5 to MSX 2000 and don't touch the CF
server, you should be OK.
* If, after you upgrade from MDX 5.5 to 2000 and rebuild the CF server,
you will have problems in that OWA 5.5 won't connect to an existing MSX
2000 server. Therefore, you can't get CF5/CFMX to connect to MSX
either.
My final solution is to use ASP/ADO running on the actual MSX 2000
server itself. Since the thread I posted in a previous message contains
the actual CF code to connect to MSX 5.5 or 2000, I'll only add the
following ASP code that lets me connect to MSX via ADO using ASP.
The main caveat to this is you must enable IIS authentication so your
credentials pass through to Exchange. This is totally different where
with the CF example, you let the CF service account have access to all
the mailboxes in Exchange. ASP, on the other hand, uses the credentials
of the user currently logged on to the browser session.
Oh, well, here is the ASP code (this may be forbidden on a CF-related
list...)
As mentioned above, this code sample must be run on an IIS web site on
an Exchange 2000 server. The directory must have also IIS
authentication enabled.
This sample connects to an Exchange mailbox to pull calendar events.
Since all dates are stored in UTC or GMT within the Exchange database, I
had to create some functions to convert it to Central Standard Time (not
yet complete).
<% @LANGUAGE = "VBScript" %>
<%
Function DSTStartDateForYear(DateIn)
'Returns last Sunday in October for the year of the given date
'Daylight Saving Time starts the last Sunday of October at 2:00
am
Dim ThisDay, ThisDate
For ThisDay = 31 To 1 Step -1
'Build date string for the month of October
ThisDate = Year(DateIn) & "-10-" & ThisDay
'Return the date of the last Sunday found
If Instr(1, FormatDateTime(ThisDate, 1), "Sunday", 1)
Then
DSTStartDateForYear = ThisDate
Exit For
End If
Next
End Function
Function DSTEndDateForYear(DateIn)
'Returns first Sunday in April for the year of the given date
'Daylight Saving Time ends the first Sunday of April at 2:00 am
Dim ThisDay, ThisDate
For ThisDay = 1 To 30 Step 1
'Build date string for month of April
ThisDate = Year(DateIn) & "-4-" & ThisDay
'Return the date of the first Sunday found
If Instr(1, FormatDateTime(ThisDate, 1), "Sunday", 1)
Then
DSTEndDateForYear = ThisDate
Exit For
End If
Next
End Function
servername = Request.ServerVariables("SERVER_NAME")
Mailboxname = "your mailbox name goes here"
inboxURL = "http://" & servername & "/Exchange/" & mailboxname &
"/Calendar/"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "ExOLEDB.DataSource"
conn.Open inboxURL
strSQL = "SELECT ""urn:schemas:httpmail:subject"", " &_
"""urn:schemas:calendar:busystatus"", " & _
"""urn:schemas:httpmail:priority"", " & _
"""urn:schemas:httpmail:date"", " & _
"""urn:schemas:calendar:dtstart"", " & _
"""urn:schemas:calendar:dtend"", " & _
"""urn:schemas:calendar:location"", " & _
"""urn:schemas:calendar:alldayevent"", " & _
"""urn:schemas:httpmail:textdescription"", " & _
"""DAV:displayname""" & _
" FROM SCOPE('shallow traversal of """ & inboxURL & """')" & _
" WHERE ""DAV:ishidden"" = False AND ""DAV:isfolder"" = False" & _
" ORDER BY ""urn:schemas:calendar:dtstart"""
Response.Write "<p>" & strSQL & "</p>"
Set rs = conn.Execute(strSQL)
rs.MoveFirst
n = 0
Do While (Not rs.EOF)
n = n + 1
rs.MoveNext
Loop
Response.Write n & " records returned<br> <br>" & vbLf
rs.MoveFirst
Do While (Not rs.EOF)
%>
<hr>
<%
ApptStartTime = rs("urn:schemas:calendar:dtstart")
ApptEndTime = rs("urn:schemas:calendar:dtend")
StartDiff = DateDiff("d", DSTStartDateForYear(ApptStartTime),
ApptStartTime)
EndDiff = DateDiff("d", DSTEndDateForYear(ApptStartTime), ApptStartTime)
If StartDiff < 0 And EndDiff >= 0 Then
DSTFlag = "Event started in Standard Time"
Else
DSTFlag = "Event started in Daylight Saving Time"
End If
%>
<% = DSTFlag %><br>
Busy Status <% = rs("urn:schemas:calendar:busystatus") %><br>
Priority <% = rs("urn:schemas:httpmail:priority") %><br>
<strong>DST Start Date (AppStartTime):</strong> <% =
DSTStartDateForYear(ApptStartTime) %><br>
<strong>DST End Date (AppStartTime):</strong> <% =
DSTEndDateForYear(ApptStartTime) %><br>
<strong>Subject:</strong> <% =
Server.HTMLEncode(rs("urn:schemas:httpmail:subject")) %><br>
<strong>(Exchange) Appt Start Time:</strong> <% = ApptStartTime %><br>
<strong>(Exchange) Appt End Time:</strong> <% = ApptEndTime %><br>
<!--- <strong>Location:</strong> <% =
rs("urn:schemas:calendar:location") %><br> --->
<strong>All Day Event:</strong> <% =
rs("urn:schemas:calendar:alldayevent") %><br>
<!--- <strong>Text Description:</strong> <% =
rs("urn:schemas:httpmail:textdescription") %><br> --->
<%
rs.MoveNext
Loop
Set rs = Nothing
Set conn = Nothing
%>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).