In my pervious post I showed how to create a simple LCS scripted response bot that did something a little bit boring such as tell you what day it is. Presence technology is something that’s changing and growing all the time the Outlook integration of the Office 2005 communicator is one example. The script is partially inspired by this but I decided to see if I could push the limits when it comes to privacy and the presence type information that is available to system administrators that you may not think normally about using.
So what does this bot do ? The bot allows you to ask it the question where is firstname.lastname@example.org. It then takes this information and does the following
First it queries the calendar to see if they are currently in an appointment and creates a response that shows details of the appointment a person may currently be attending and the location that appointment is and what time it started and finished. It also sends a full list of their calendar appointments over the next 8 hours what time they start and finish and where they are located.
After this it does a query of the users Inbox and looks for any email that the asker has sent to this user over the past 3 days and see’s if any of these emails are unread. If any of these emails are marked unread in the users inbox it creates a list of which email they are and responds to the requestor.
After this it does a query of the users Sent items folder and looks at the last time the user sent an email. It doesn’t look at the details of the actual message it just returns back to the asker the time the last email was sent. (This is to give the asker an impression of when the last time this user was actively sending email)
The last query it does if for Exchange 2003 server only what it does is queries the Exchange_logon class to see if this user is currently logged on to the Exchange server anywhere. So basically it tells the users if this person is currently logged onto Outlook from a desktop or whether they are logged on maybe via Outlook web Access.
An Example of the Output it returns looks like.
For detail on the response bot itself see my other post the Exchange whereis function does a number of queries to gather the information I described above. The first thing that happens however is that the email address of the user that is the subject of the who is first is queried in Active Directory to work out what exchange server there mailbox is located on. Another ADSI query is done to find the primary email address from the asker's sip address which is necessary for the unread email query
All the mailbox queries are performed over WebDAV I’ve created two versions of this script one is for if your running FBA on the Exchange server and the other is a NTLM version. For the Logon status query I’ve used a version of one of my previous scripts that uses the ADO shaping data provider to shape ADSI and Logon Data from the Exchange_Logon class to show the logon status of the user. Because this script actually logs onto a users mailbox the script must filter out any logons that I picks up that the script has made. Because of the number of queries performed and depending on the number of items in a mailbox it can take a little time for all the queries to complete. To show a recognition that it has excepted the query it responds back to the user straight away that its checking and to wait a minute.
To run this script can be a little tricky basically you need to configure the script with credentials to use to logon to LCS and logon to Exchange. I’ve used the same credentials for both LCS and Exchange meaning that the user who your are using in the script must have full rights to all the Exchange mailboxes that might be queried by this script. See this for more details on how to achieve this.
To run this script you first need to configure the following four variables at the top of the script
SipURI = "email@example.com"
Servername = "servername.domain.com"
userName = "domain\username"
Password = "password"
One note if your running the FBA version and you have a fount end server you might want to hardcode the name of the fount end server in the script. This can be important if you have used an alias in your SSL certificate which would normally cause a SSL certificate popup which will cause the script to fail. To hardcode the server name just un-rem the following line of code and configure the variable.
'exservername = "frontend.domain.com" ' If you have a frount end server you can hardcode servername here
After you’ve configured the script all you need to do is start it from the command shell like.
The script is very verbose and should return a lot of information back to the console while it’s running.
I’ve put a downloadable copy of the script here The script itself is a little large to post in verbatim