Skip to main content

Adding Document Favorite links for Direct File Access in OWA 2007 via a script

Direct File access is a pretty cool feature of OWA 2007 although may not be the easiest thing for your average user to get their head around. Somebody asked a question about pre-populating the favorites for a user which is a pretty good idea (actually when you think about it you really want something that’s policy driven). Currently there is no really easy or supported way of doing this programmatically. The document links themselves are stored in a storage item with a messageclass of IPM.Configuration.Owa.DocumentLibraryFavorites in the associated folder collection of NON_IPM_Subtree root of a mailbox. On this storage item there is a binary mapi property 0x7C080102 and the links are stored in a XML document.

I decided to see if I could write a script that could open this storage item and then add some nodes into the already existing property or create the property if it didn’t exist. The format of the doclib node looks something like

<docLib uri="file://sername/directory" dn="DisplayName"
hn="servername" uf="2"/>

This isn’t documented anywhere so I can only hazard to guess at that these elements actually mean but logically I would think

Uri - Path to the directory or sharepoint server

Dn – The displayName in OWA

Hn – HostName ?

Uf – This property seems to get set to one of 3 values which affects the way the icon shows in OWA if you have added just a hostname then it gets set to 2, if you add a share mapping it gets set to 6 if you added a deep url mapping eg a couple of directorys deep it gets set to 34.

From what I’ve noticed the IPM.Configuration.Owa.DocumentLibraryFavorites storage item only gets created the first time the user click on the documents link in OWA so the item wouldn’t be there normally if the user has not logged onto OWA or has never clicked this link.

As I said this script is unsupported and pretty untested and should only be used in test/dev environment. Also make sure you know how to use a Mapi editor like Outlook Spy or mfcMapi worse case is you’ll stuff up the IPM.Configuration.Owa.DocumentLibraryFavorites object and need to delete it.

The script uses CDO 1.2 to use the script you need to configure the first 4 lines which reflect the doclib I just talked about,

shareDN = "temp"
ShareHostName = "servername"
Shareuf = "6"
ShareURI = "file://servername/temp"

and then the 6,7 with the servername and mailboxname of the mailbox you want to access.

I’ve put a download of the script here the code itself look like

shareDN = "temp"
ShareHostName = "servername"
Shareuf = "6"
ShareURI = "file://servername/temp"

snServername = "mailserver"
mbMailboxName = "mailbox"

Const PR_PARENT_ENTRYID = &H0E090102
set xdXmlDocument = CreateObject("Microsoft.XMLDOM")
xdXmlDocument.async="false"
ifound = false
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "","",false,true,true,true,snServername & vbLF & mbMailboxName
Set CdoInfoStore = objSession.GetInfoStore
Set CdoFolderRoot = CdoInfoStore.RootFolder
set non_ipm_rootfolder =
objSession.getfolder(CdoFolderRoot.fields.item(PR_PARENT_ENTRYID),CdoInfoStore.id)
For Each soStorageItem in non_ipm_rootfolder.HiddenMessages
If soStorageItem.Type = "IPM.Configuration.Owa.DocumentLibraryFavorites" Then
ifound = true
Set actionItem = soStorageItem
End if
Next
If ifound = false Then
wscript.echo "No Storage Item Found"
Else
On Error Resume Next
hexString = actionItem.fields(&h7C080102).Value
If Err.number <> 0 Then
On Error goto 0
wscript.echo "Property not set"
actionItem.fields.Add &h7C080102, vbBlob
actionItem.fields(&h7C080102).Value = StrToHexStr("<docLibs></docLibs>")
actionItem.update
hexString = actionItem.fields(&h7C080102).Value
End If
On Error goto 0
wscript.echo hextotext(hexString)
xdXmlDocument.loadxml(hextotext(hexString))
Set xnNodes = xdXmlDocument.selectNodes("//docLibs")
update = false
Call Adddoclib(shareDN,ShareHostName,Shareuf,ShareURI,xnNodes)
If update = True Then
nval = StrToHexStr(CStr(xdXmlDocument.xml))
actionItem.fields(&h7C080102).Value = nval
actionItem.update
wscript.echo "Storage Object Updated"
Else
wscript.echo "No Updates Performed"
End If
End If



Function hextotext(binprop)
arrnum = len(binprop)/2
redim aout(arrnum)
slen = 1
for i = 1 to arrnum
if CLng("&H" & mid(binprop,slen,2)) <> 0 then
aOut(i) = chr(CLng("&H" & mid(binprop,slen,2)))
end if
slen = slen+2
next
hextotext = join(aOUt,"")
end Function

Function StrToHexStr(strText)
Dim i, strTemp
For i = 1 To Len(strText)
strTemp = strTemp & Right("0" & Hex(Asc(Mid(strText, i, 1))), 2)
Next
StrToHexStr = Trim(strTemp)
End Function

Function Searchfordoclib(elElementName,cnvalue,XMLDoc)
Set xnSearchNodes = XMLDoc.selectNodes("//*[@" & elElementName & " = '" &
cnvalue & "']")
If xnSearchNodes.length = 0 Then
Searchfordoclib = False
else
Searchfordoclib = True
End if

End Function

sub Adddoclib(dn,hn,uf,uri,xnNodes)
If Searchfordoclib("dn",dn,xdXmlDocument) = False then
Set objnewEle = xdXmlDocument.createElement("docLib")
objnewEle.setAttribute "uri",uri
objnewEle.setAttribute "dn",dn
objnewEle.setAttribute "hn", hn
objnewEle.setAttribute "uf", uf
xnNodes(0).appendchild objnewEle
update = true
Else
wscript.echo "Dn exists " & DN
End if
End sub

Popular posts from this blog

Testing and Sending email via SMTP using Opportunistic TLS and oAuth in Office365 with PowerShell

As well as EWS and Remote PowerShell (RPS) other mail protocols POP3, IMAP and SMTP have had OAuth authentication enabled in Exchange Online (Official announcement here ). A while ago I created  this script that used Opportunistic TLS to perform a Telnet style test against a SMTP server using SMTP AUTH. Now that oAuth authentication has been enabled in office365 I've updated this script to be able to use oAuth instead of SMTP Auth to test against Office365. I've also included a function to actually send a Message. Token Acquisition  To Send a Mail using oAuth you first need to get an Access token from Azure AD there are plenty of ways of doing this in PowerShell. You could use a library like MSAL or ADAL (just google your favoured method) or use a library less approach which I've included with this script . Whatever way you do this you need to make sure that your application registration  https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-

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 Graph is limited to a m

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 I wrote th
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.