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.

This entry was posted in Exchange 2003, VBScript and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">