• Sign in
 
  •  
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • About
  • Email Blog Author
  • RSS for posts
  • Atom
  • RSS for comments
    • OK
  • CDO (25)
  • Code Snippet (43)
  • Custom Providers (17)
  • Debugging (7)
  • DevMsgTeam (303)
  • Documentation (111)
  • DST (8)
  • EWS (7)
  • Exchange (110)
  • Gotchas (98)
  • Hotfix (28)
  • MAPI (241)
  • MAPI Download (55)
  • MFCMAPI (102)
  • MSDN (59)
  • Non Dev (11)
  • OOM (17)
  • Outlook (171)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (12)
  • Protocol Docs (20)
  • PST/OST (23)
  • Referrals (8)
  • Vista (12)
  • WrapPST (18)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2013 (5)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (2)
  • January 2013 (2)
  • December 2012 (4)
  • November 2012 (2)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (3)
  • June 2012 (2)
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)
Blogs I Read
  • Exchange

  • Raymond Chen [MSFT]

  • Larry Osterman [MSFT]

  • Peter David

  • Aaron Margosis [MSFT]

  • Jason Johnston [MSFT]

  • Matt Stehle (MSFT)

  • Patrick Creehan [MSFT]

  • Ryan Gregg [MSFT]

    Outlook PM
  • WebDav 101

    Dan Bagley (MSFT)
  • Dave Vespa [MSFT]

  • Randy Topken

    Outlook EE

April, 2007

MSDN Blogs > SGriffin's MAPI Internals > April, 2007
  • Subscribe via RSS
Sort by: Most Recent | Most Views | Most Comments
Excerpt View | Full Post View
  • SGriffin's MAPI Internals

    Detecting the Version Of Exchange in a Profile

    Posted over 6 years ago
    by Stephen Griffin - MSFT
    • 6 Comments

    [This is now documented here: http://msdn2.microsoft.com/en-us/library/bb820967.aspx]

    We had some folks asking recently if there's a property in the profile you can use to determine what version of Exchange the mailbox in the profile is on. It turns out there is, but it's not guaranteed to be there, and it changes in Outlook 2007.

    First, the pre-Outlook 2007 property: The version of emsmdb32.dll that comes with Outlook 2003 and earlier and with all of Exchange's implementations of MAPI will write the property PR_PROFILE_SERVER_VERSION into the global profile section of the profile. This property was previously discussed in Jason's blog posting on GC Reconnect. This property is a PT_LONG, and will typically contain partial information about the build of the Exchange server. However, the data contained in this property is not encoded consistently between different versions of Exchange.

    For instance, against my test Exchange 2003 server, I see this property contains 6944 decimal - the version of store.exe on this server is 6.5.6944.3. Against my test Exchange 2007 server, I see the property contains 33453 decimal, which is 0x82AD hex. 0x2AD hex is 685 decimal. The version of store on my test Exchange 2007 server is 8.0.685.24, so we see the major version and build numbers were encoded in the property.

    The developers of Outlook 2007 wanted more granularity out of the version. The conversation emsmdb32 conducts with the Exchange server actually contains the full version information. But that's too much to stick in a PT_LONG. So they created a new property, PR_PROFILE_SERVER_FULL_VERSION, which is a PT_BINARY. This allows us to store a EXCHANGE_STORE_VERSION_NUM structure with both the major and minor version numbers and the major and minor build numbers (note: this is the same format used by PR_REPLICA_VERSION). When we look at an Outlook 2007 profile connecting to the above servers, we see the full version information is available.

    Some comments:

    • There's no guarantee you'll find these properties in a profile. If they're there, emsmdb32 can use them to make some decisions during connection (such as noted in Jason's blog). However, regardless of what's in them, when emsmdb32 connects to the Exchange server, it will rewrite them. Note that after applying a hotfix to the Exchange server you'll probably see these numbers bump up on subsequent connections.
    • Only one of these properties is likely to be in a profile. Outlook 2007 no longer reads or writes PR_PROFILE_SERVER_VERSION. I haven't tested the upgrade scenario, so if you're writing code to check these properties, you should check PR_PROFILE_SERVER_FULL_VERSION first.
    • These properties are of no help in detecting whether or not it's safe to pass CONNECT_IGNORE_NO_PF. They don't get written until after a successful connection, and if you need CONNECT_IGNORE_NO_PF, you won't connect successfully until it's set. Catch-22.
    • If you're using the Outlook 2007 object model, you may want to look at NameSpace.ExchangeMailboxServerVersion.

    Here's a function I wrote to demonstrate how to fetch these properties:

    #define PR_PROFILE_SERVER_VERSION      PROP_TAG( PT_LONG, 0x661B)
    #define PR_PROFILE_SERVER_FULL_VERSION PROP_TAG( PT_BINARY, 0x663B)
    
    typedef struct
    {
    	WORD	wMajorVersion;
    	WORD	wMinorVersion;
    	WORD 	wBuild;
    	WORD 	wMinorBuild;
    } EXCHANGE_STORE_VERSION_NUM;
    
    HRESULT GetProfileServiceVersion(LPSTR lpszProfileName,
    								 ULONG* lpulServerVersion,
    								 WORD* lpwMajorVersion,
    								 WORD* lpwMinorVersion,
    								 WORD* lpwBuild,
    								 WORD* lpwMinorBuild,
    								 BOOL* lpbFoundServerVersion,
    								 BOOL* lpbFoundServerFullVersion)
    {
    	if (!lpszProfileName 
    		|| !lpulServerVersion
    		|| !lpwMajorVersion
    		|| !lpwMinorVersion
    		|| !lpwBuild
    		|| !lpwMinorBuild
    		|| !lpbFoundServerVersion
    		|| !lpbFoundServerFullVersion) return MAPI_E_INVALID_PARAMETER;
    	*lpbFoundServerVersion = false;
    	*lpbFoundServerFullVersion = false;
    	
    	HRESULT        hRes= S_OK;
    	LPPROFADMIN    lpProfAdmin = NULL;
    	LPSERVICEADMIN lpServiceAdmin = NULL;
    	
    	hRes = MAPIAdminProfiles(0, &lpProfAdmin);
    	if (!lpProfAdmin) return hRes;
    	
    	hRes = lpProfAdmin->AdminServices(
    		(LPTSTR)lpszProfileName,
    		_T(""), 
    		0,
    		0,
    		&lpServiceAdmin);
    	
    	if (lpServiceAdmin)
    	{
    		LPPROFSECT lpProfSect = NULL;
    		hRes = lpServiceAdmin->OpenProfileSection(
    			(LPMAPIUID)pbGlobalProfileSectionGuid,
    			NULL,
    			0,
    			&lpProfSect);
    		if (lpProfSect)
    		{
    			LPSPropValue lpServerVersion = NULL;
    			hRes = HrGetOneProp(lpProfSect,PR_PROFILE_SERVER_VERSION,&lpServerVersion);
    			
    			if (SUCCEEDED(hRes) && lpServerVersion && PR_PROFILE_SERVER_VERSION == lpServerVersion->ulPropTag)
    			{
    				*lpbFoundServerVersion = true;
    				*lpulServerVersion = lpServerVersion->Value.l;
    			}
    			MAPIFreeBuffer(lpServerVersion);
    			
    			LPSPropValue lpServerFullVersion = NULL;
    			hRes = HrGetOneProp(lpProfSect,PR_PROFILE_SERVER_FULL_VERSION,&lpServerFullVersion);
    			
    			if (SUCCEEDED(hRes) && 
    				lpServerFullVersion && 
    				PR_PROFILE_SERVER_FULL_VERSION == lpServerFullVersion->ulPropTag)
    			{
    				if (lpServerFullVersion->Value.bin.cb == sizeof(EXCHANGE_STORE_VERSION_NUM))
    				{
    					EXCHANGE_STORE_VERSION_NUM* lpStoreVersion = 
    						(EXCHANGE_STORE_VERSION_NUM*)(lpServerFullVersion->Value.bin.lpb);
    					
    					*lpbFoundServerFullVersion = true;
    					*lpwMajorVersion = lpStoreVersion->wMajorVersion;
    					*lpwMinorVersion = lpStoreVersion->wMinorVersion;
    					*lpwBuild = lpStoreVersion->wBuild;
    					*lpwMinorBuild = lpStoreVersion->wMinorBuild;
    				}
    			}
    			MAPIFreeBuffer(lpServerFullVersion);
    			
    			lpProfSect->Release();
    		}
    		lpServiceAdmin->Release();
    	}
    	
    	lpProfAdmin->Release();
    	
    	// If we found any server version, consider the call a success
    	if (*lpbFoundServerVersion || *lpbFoundServerFullVersion) hRes = S_OK;
    	
    	return hRes;
    }
Page 1 of 1 (1 items)
  • © 2013 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy & Cookies
  • Report Abuse
  • 5.6.426.415