Exchange 2013 & iPhone Sync

Today I’ve got an iPhone unable to sync with Exchange 2013. Curiously, only the inbox was not syncing. All other folders were working fine.

Checking into event logs I’ve found one error related to the sync problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
An exception occurred and was handled by Exchange ActiveSync. This may have been caused by an outdated or corrupted Exchange ActiveSync device partnership. This can occur if a user tries to modify the same item from multiple computers. If this is the case, Exchange ActiveSync will re-create the partnership with the device. Items will be updated at the next synchronization.

URL=
--- Exception start ---
Exception type: Microsoft.Exchange.Data.Storage.SyncStateExistedException
Exception message: The sync state named 2 already exists.
Exception level: 0
Exception stack trace: at Microsoft.Exchange.Data.Storage.SyncState.CreateSyncStateFolderInFolder(SyncStateInfo syncStateInfo, Folder syncStateParentFolder, PropertyDefinition[] properties, Object[] values, ISyncLogger syncLogger)
at Microsoft.Exchange.Data.Storage.SyncState.CreateSyncStateStoreObject(SyncStateStorage syncStateStorage, SyncStateInfo syncStateInfo, Folder syncStateParentFolder, PropertyDefinition[] properties, Object[] values, ISyncLogger syncLogger)
at Microsoft.Exchange.Data.Storage.FolderSyncState.CreateSyncState(SyncStateStorage syncStateStorage, Folder syncStateParentFolder, ISyncProviderFactory syncProviderFactory, String syncFolderId, ISyncLogger syncLogger)
at Microsoft.Exchange.Data.Storage.SyncStateStorage.CreateFolderSyncState(ISyncProviderFactory syncProviderFactory, String syncFolderId)
at Microsoft.Exchange.AirSync.SyncCollection.OpenSyncState(Boolean autoLoadFilterAndSyncKey, SyncStateStorage syncStateStorage)
at Microsoft.Exchange.AirSync.SyncCommand.SyncTheCollection(SyncCollection collection, Boolean createSubscription, Boolean tryNullSync)
at Microsoft.Exchange.AirSync.SyncCommand.OnExecute()
at Microsoft.Exchange.AirSync.SyncCommand.ExecuteCommand()
at Microsoft.Exchange.AirSync.Command.WorkerThread()
Inner exception follows below:
Exception type: Microsoft.Exchange.Data.Storage.ObjectExistedException
Exception message: Could not create folder 2.
Exception level: 1
Exception stack trace: at Microsoft.Exchange.Data.Storage.FolderCreatePropertyBag.CreateMapiFolder()
at Microsoft.Exchange.Data.Storage.FolderCreatePropertyBag.SaveFolderPropertyBag(Boolean needVersionCheck)
at Microsoft.Exchange.Data.Storage.CoreFolder.Save(SaveMode saveMode)
at Microsoft.Exchange.Data.Storage.Folder.Save(SaveMode saveMode)
at Microsoft.Exchange.Data.Storage.SyncState.CreateSyncStateFolderInFolder(SyncStateInfo syncStateInfo, Folder syncStateParentFolder, PropertyDefinition[] properties, Object[] values, ISyncLogger syncLogger)
Inner exception follows below:
Exception type: Microsoft.Mapi.MapiExceptionCollision
Exception message: MapiExceptionCollision: Unable to create folder. (hr=0x80040604, ec=-2147219964)
Diagnostic context:
Lid: 55847 EMSMDBPOOL.EcPoolSessionDoRpc called [length=116]
Lid: 43559 EMSMDBPOOL.EcPoolSessionDoRpc returned [ec=0x0][length=220][latency=0]
Lid: 52176 ClientVersion: 15.0.1076.9
Lid: 50032 ServerVersion: 15.0.1076.6009
Lid: 23226 --- ROP Parse Start ---
Lid: 27962 ROP: ropCreateFolder [28]
Lid: 17082 ROP Error: 0x80040604
Lid: 25953
Lid: 21921 StoreEc: 0x80040604
Lid: 27962 ROP: ropExtendedError [250]
Lid: 1494 ---- Remote Context Beg ----
Lid: 41352 qdwParam: 0x8D29C49F7F66A52
Lid: 55033 dwParam: 0x0
Lid: 10786 dwParam: 0x0 Msg: 15.00.1076.000:LITIO
Lid: 1750 ---- Remote Context End ----
Lid: 31418 --- ROP Parse Done ---
Lid: 22417
Lid: 30609 StoreEc: 0x80040604
Lid: 29073
Lid: 20369 StoreEc: 0x80040604
Lid: 63664
Lid: 40448 StoreEc: 0x80040604
Exception level: 2
Exception stack trace: at Microsoft.Mapi.MapiExceptionHelper.InternalThrowIfErrorOrWarning(String message, Int32 hresult, Boolean allowWarnings, Int32 ec, DiagnosticContext diagCtx, Exception innerException)
at Microsoft.Mapi.MapiExceptionHelper.ThrowIfError(String message, Int32 hresult, IExInterface iUnknown, Exception innerException)
at Microsoft.Mapi.MapiFolder.InternalCreateFolder(String folderName, String folderComment, Boolean openIfExists, Boolean createSearchFolder, Boolean instantSearch, Boolean optimizedConversationSearch, Boolean createPublicFolderDumpster, Byte[] folderId, Boolean createInternalAccess)
at Microsoft.Exchange.Data.Storage.FolderCreatePropertyBag.CreateMapiFolder()
--- Exception end ---.

The basics were already coverd by the help desk team.

First, I’ve tried to check and remove the mobile partnership linked to the Mailbox.

1
Get-MobileDevice -Mailbox johndoe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
RunspaceId : c42a3abe-e15a-4999-b0d0-8a8aa90a4299
FriendlyName : iPhone 5s
DeviceId : ApplDNPM4HW2FFGD
DeviceImei :
DeviceMobileOperator :
DeviceOS : iOS 8.3 12F70
DeviceOSLanguage : pt
DeviceTelephoneNumber :
DeviceType : iPhone
DeviceUserAgent : Apple-iPhone6C2/1206.70
DeviceModel : iPhone6C2
FirstSyncTime : 26/05/2014 20:13:19
UserDisplayName : mydomain.local/Usuários/John Doe
DeviceAccessState : Allowed
DeviceAccessStateReason : Global
DeviceAccessControlRule :
ClientVersion : 14.1
ClientType : EAS
IsManaged : False
IsCompliant : False
IsDisabled : False
AdminDisplayName :
ExchangeVersion : 0.10 (14.0.100.0)
Name : iPhone§ApplDNPM4HW2FFGD
DistinguishedName : CN=iPhone§ApplDNPM4HW2FFGD,CN=ExchangeActiveSyncDevices,CN=John Doe,OU=Usuários,DC=mydomain,DC=local
Identity : mydomain.local/Usuários/John Doe/ExchangeActiveSyncDevices/iPhone§ApplDNPM4HW2FFGD
Guid : daec6592-9203-4031-b825-628466e311e1
ObjectCategory : myforest.local/Configuration/Schema/ms-Exch-Active-Sync-Device
ObjectClass : {top, msExchActiveSyncDevice}
WhenChanged : 04/06/2015 11:41:00
WhenCreated : 26/05/2014 17:13:20
WhenChangedUTC : 04/06/2015 14:41:00
WhenCreatedUTC : 26/05/2014 20:13:20
OrganizationId :
Id : mydomain.local/Usuários/John Doe /ExchangeActiveSyncDevices/iPhone§ApplDNPM4HW2FFGD
OriginatingServer : TITANIO
IsValid : True
ObjectState : Unchanged
1
Remove-MobileDevice "mydomain.local/Usuários/John Doe/ExchangeActiveSyncDevices/iPhone§ApplDNPM4HW2FFGD"

The command executed without errors. So far things behaved as expected, but when I get mobile partnerships again, I get the same partnership as if it had never been deleted.

After walking in circles I’ve tried a long shoot. Seems that something was corrupted. Let’s check the user mailbox.

1
New-MailboxRepairRequest -Mailbox johndoe -CorruptionType ProvisionedFolder,SearchFolder,AggregateCounts,Folderview
1
Get-MailboxRepairRequest -mailbox johndoe | fl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
RunspaceId : c42a3abe-e15a-4999-b0d0-8a8aa90a4299
Identity : a0598b5b-82db-45a7-8309-4ba865de95e2\6213348d-47c7-4ff5-8a44-9f7151039311\ef8f1654-bfeb-4786-a03f
-2b0b238fdf72
Mailbox : d59341d9-d810-4291-b70e-b6c2ede007c6
Source : OnDemand
Priority : Normal
DetectOnly : False
JobState : Succeeded
Progress : 100
Tasks : {AggregateCounts}
CreationTime : 03/08/2015 18:34:01
FinishTime : 03/08/2015 18:35:05
LastExecutionTime : 03/08/2015 18:35:05
CorruptionsDetected : 4
ErrorCode :
CorruptionsFixed : 4
TimeInServer : 00:00:43.6290000
Corruptions : {Type:AggregateCountMismatch (Fixed:True), Type:AggregateCountMismatch (Fixed:True),
Type:AggregateCountMismatch (Fixed:True), Type:AggregateCountMismatch (Fixed:True)}
IsValid : True
ObjectState : New

Bingo. After the mailbox repair the mobile partnership remove worked fine. Reconfigured the device and everything is working again.