Skip to main content

Exchange Where is scripted Instant Message response Bot using LCS and Communicator Web Access (Ajax)

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 fred@domain.com. 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.


The script

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 = "user@domain.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.

Cscript exwhoislcsrespbot.vbs

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

Popular posts from this blog

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Sending a Message in Exchange Online via REST from an Arduino MKR1000

This is part 2 of my MKR1000 article, in this previous post  I looked at sending a Message via EWS using Basic Authentication.  In this Post I'll look at using the new Outlook REST API  which requires using OAuth authentication to get an Access Token. The prerequisites for this sketch are the same as in the other post with the addition of the ArduinoJson library  https://github.com/bblanchon/ArduinoJson  which is used to parse the Authentication Results to extract the Access Token. Also the SSL certificates for the login.windows.net  and outlook.office365.com need to be uploaded to the devices using the wifi101 Firmware updater. To use Token Authentication you need to register an Application in Azure https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually  with the Mail.Send permission. The application should be a Native Client app that use the Out of Band Callback urn:ietf:wg:oauth:2.0:oob. You ...

How to test SMTP using Opportunistic TLS with Powershell and grab the public certificate a SMTP server is using

Most email services these day employ Opportunistic TLS when trying to send Messages which means that wherever possible the Messages will be encrypted rather then the plain text legacy of SMTP.  This method was defined in RFC 3207 "SMTP Service Extension for Secure SMTP over Transport Layer Security" and  there's a quite a good explanation of Opportunistic TLS on Wikipedia  https://en.wikipedia.org/wiki/Opportunistic_TLS .  This is used for both Server to Server (eg MTA to MTA) and Client to server (Eg a Message client like Outlook which acts as a MSA) the later being generally Authenticated. Basically it allows you to have a normal plain text SMTP conversation that is then upgraded to TLS using the STARTTLS verb. Not all servers will support this verb so if its not supported then a message is just sent as Plain text. TLS relies on PKI certificates and the administrative issue s that come around certificate management like expired certificates which is why ...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.