PRB: CDO (1.x) Session.CurrentUser Returns Wrong User Name (223446)
The information in this article applies to:
- Collaboration Data Objects (CDO) 1.0a
- Collaboration Data Objects (CDO) 1.1
- Collaboration Data Objects (CDO) 1.2
- Collaboration Data Objects (CDO) 1.21
This article was previously published under Q223446 SYMPTOMS
The CurrentUser property of the Collaboration Data Objects (1.x) Session object might return the Internet Mail account name instead of the Exchange user name. This problem occurs when your program logs on to a mail profile that has both Microsoft Exchange Server service and Internet E-Mail service.
CAUSE
Exchange store does not act as the provider for the primary identity until the store has been opened.
RESOLUTION
You need to have a reference to the Exchange store to get Exchange to be the provider for the primary identity.
For example, having a reference to the RootFolder of the private message store, before reading the value of the CurrentUser property solves the problem:
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , True
For Each objInfoStore In objSession.InfoStores
'Check CdoPR_PROVIDER_DISPLAY (&H3006001E)
On Error Resume Next
If InStr(objInfoStore.Fields(&H3006001E), "Microsoft Exchange") Then
Set objFolder = objInfoStore.RootFolder
Exit For
End If
Next
MsgBox "The Current User is " & objSession.Currentuser
STATUS
This behavior is by design.
REFERENCES
For more information about being a provider for the primary identity, please see the following topic on Microsoft Developer Network (MSDN):
IMAPISession::QueryIdentity
Modification Type: | Minor | Last Reviewed: | 3/4/2004 |
---|
Keywords: | kbMsg kbprb KB223446 |
---|
|