Solved

Show AD Username in Outlook

Posted on 2014-03-21
7
886 Views
Last Modified: 2014-04-10
Does anyone know of a way to show a user's AD logon/username in Outlook? When I get an email from a user, I often will have to look up their username name.

If Outlook showed me that information, it would save quite a bit of searching every day. If it helps, I am running Outlook 2013 and Exchange 2007.
0
Comment
Question by:Joseph Moody
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 11

Expert Comment

by:Giladn
ID: 39945790
try this
http://www.howto-outlook.com/howto/viewsenderaddress.htm
there is no other way or option to change the address view..

Gilad
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39946735
Hi, Jmoody10.

How about a macro that displays that information?  If a macro is acceptable, then I can post the code and instructions for using it.
0
 
LVL 22

Author Comment

by:Joseph Moody
ID: 39957078
A Macro would be probably work!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Expert Comment

by:David Lee
ID: 39957237
The macro would look the username up and add it to a custom property.  You could then customize your view to show that property.  Keep in mind that this will only work for messages you receive from folks inside your organization.  It won't work for messages you receive from anyone outside of your organization.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39958678
Here's my solution.  It works by looking up each message sender in Active Directory and retrieving their account name.  It then adds a user property called "Username" to that message and sets it to the account name.  You can then add a new column to your view to see the username field.

Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Press ALT+F11 to open the Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Click the diskette icon on the toolbar to save the changes
6.  Close the VB Editor
7.  Click File and select Options
8.  Click Trust Center
9. Click the Trust Center Settings button
10. Click Macro Settings
11. Change Macro Settings to "Notifications for all macros"
12. Click OK
13. Click OK
14. Close Outlook
15. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim arrEID As Variant, varEID As Variant, olkItm As Object, olkPrp As Object, olkExu As Object, strUsr As String
    On Error Resume Next
    arrEID = Split(EntryIDCollection, ",")
    For Each varEID In arrEID
        Set olkItm = Session.GetItemFromID(varEID)
        If olkItm.Class = olMail Then
            Set olkExu = olkItm.Sender.GetExchangeUser
            If TypeName(olkExu) = "Nothing" Then
                strUsr = "Unknown"
            Else
                strUsr = GetUsernameFromAlias(olkExu.Alias)
            End If
            Set olkPrp = olkItm.UserProperties.Add("Username", olText, True)
            olkPrp.value = strUsr
            olkItm.Save
            Set olkPrp = Nothing
        End If
    Next
    On Error GoTo 0
    Set olkItm = Nothing
    Set olkExu = Nothing
End Sub

Function GetUsernameFromAlias(strAls As String) As String
    Dim adoCon As Object, adoRec As Object, objDSE As Object, strDNC As String, strSrc As String
    Set objDSE = GetObject("LDAP://RootDSE")
    strDNC = objDSE.get("defaultnamingcontext")
    strSrc = "'LDAP://" & strDNC & "'"
    Set adoCon = CreateObject("ADODB.Connection")
    adoCon.Provider = "ADsDSOObject"
    adoCon.CursorLocation = 3
    adoCon.Open "ADSI"
    Set adoRec = adoCon.Execute("SELECT samAccountName FROM " & strSrc & " Where objectClass='user' AND objectCategory='Person' AND mailNickname='" & strAls & "'")
    If Not adoRec.BOF And Not adoRec.EOF Then
        GetUsernameFromAlias = adoRec.Fields("samAccountName").value
    Else
        GetUsernameFromAlias = "Not Found"
    End If
    adoRec.Close
    adoCon.Close
    Set adoRec = Nothing
    Set adoCon = Nothing
    Set objDSE = Nothing
End Function

Open in new window

0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 39992422
This is wonderful!!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39992525
Cool.  I'm glad you like it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question