Populating Outlook forms with AD User Attributes

Did you ever want an Custom Outlook Form to automatically populate a Custom Outlook Field with the Active Directory .displayName of the logged on user?

The code below populates the custom Outlook Fields “LOUDisplay”,”LOUGivenName”,”LOUSN” upon the creation of the Form.

This action does not repeat if the item is re-opened. This is restricted because the code is initiated only when the Item_Open() event occurs and Item.size = “0” or newly generated. You will have to add this code in the Visual Basic part of the Custom Form.

Function Item_Open()
If Item.Size = "0" Then 'Item is New
Set objSysInfo = CreateObject("ADSystemInfo")
objUser = objSysInfo.UserName
Set ADOUser = GetObject("LDAP://"&objUser)
StrDisplayName = ADOUser.displayName
StrGivenName = ADOUser.givenName
StrSN = ADOUser.SN
Item.UserProperties("LOUDisplay") = StrDisplayName
Item.UserProperties("LOUGivenName") = StrGivenName
Item.UserProperties("LOUSN") = StrSN
Else 'Item Exists
End If
End Function

If you want any other properties for the logged on user accessing the Form just add to the fields pulled from ADUser and link to the required custom field.

Hope this helps.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s