在Exchange ActiveSync客户端上实施设置



我正在尝试编写一个支持Exchange活动同步策略的客户端。目前,我在执行规定步骤时遇到了困难。我一直在遵循微软的文档,并检查了其他几个例子,我认为我正在采取正确的步骤。

首先,我发送一个ProvisionCmd,它确实返回了一个带有临时策略密钥的策略。

其次,我发送第二个ProvisionCmd,其中包含步骤1中的策略密钥。然而,对该确认的响应看起来与步骤1中的响应相同。这让我相信这种承认并没有真正发生。

尝试其他Cmd,如FolderSync,随后会得到状态代码为142(DeviceNotProvisioned)的响应,这表明服务器认为我没有被配置。

如果服务器没有为我的用户强制执行策略,我可以成功使用EAS协议(同步电子邮件、日历等)。所以我相信Exchange的设置是正确的。我跳供养舞的方式一定有问题。

步骤1:首次供应请求:

Request:
POST /Microsoft-Server-ActiveSync?User=user8&DeviceId=482049E2C44C47E38438410E418E9B02&DeviceType=iPhone&Cmd=Provision HTTP/1.1
Host: mail.blahtest.com
Content-Type: application/vnd.ms-sync.wbxml
X-MS-PolicyKey: 3769048351
Content-Length: 85
Connection: close
Proxy-Connection: close
Cookie: X-BackEndCookie=S-1-5-21-1158204237-3780276595-2398335240-1113=u56Lnp2ejJqBm5nNx8bOyZ3Sz5ubyNLLns7G0saazszSzZudnJmcmsbHzszNgYHOztDOz9DNz87L38bFysfFy8nfr7I=
User-Agent: CS Mail/1.0.5 (iPhone Simulator; iOS 8.1; Scale/2.00)
MS-ASProtocolVersion: 14.1
Authorization: Basic <snip>
Accept-Encoding: gzip
<?xml version="1.0" encoding="utf-8"?>
<provision:Provision xmlns:provision="Provision:" xmlns:settings="Settings:">
    <settings:DeviceInformation>
        <settings:Set>
            <settings:Model>iPhone Simulator</settings:Model>
            <settings:OS>iPhone OS8.1</settings:OS>
        </settings:Set>
    </settings:DeviceInformation>
    <provision:Policies>
        <provision:Policy>
            <provision:PolicyType>MS-EAS-Provisioning-WBXML</provision:PolicyType>
        </provision:Policy>
    </provision:Policies>
</provision:Provision>

Response:
HTTP/1.1 200 OK
Content-Type: application/vnd.ms-sync.wbxml
Content-Encoding: gzip
request-id: 51d04ea0-a14d-4ec7-8784-39e46668eb2a
X-TargetBEServer: blahtest.blahtest.com
X-DiagInfo: blahtest
Set-Cookie: X-BackEndCookie=S-1-5-21-1158204237-3780276595-2398335240-1113=u56Lnp2ejJqBm5nNx8bOyZ3Sz5ubyNLLns7G0saazszSzZudnJmcmsbHzszNgYHOztDOz9DNz87L38bFysfFy8nfr7I=; expires=Mon, 10-Nov-2014 21:58:46 GMT; path=/Microsoft-Server-ActiveSync; secure; HttpOnly
X-FEServer: blahtest
Date: Mon, 10 Nov 2014 21:48:46 GMT
Connection: close
Content-Length: 342
<?xml version="1.0"?>
<provision:Provision xmlns:airsync="AirSync" xmlns:provision="Provision" xmlns:settings="Settings">
    <settings:DeviceInformation>
        <settings:Status>1</settings:Status>
    </settings:DeviceInformation>
    <provision:Status>1</provision:Status>
    <provision:Policies>
        <provision:Policy>
            <provision:PolicyType>MS-EAS-Provisioning-WBXML</provision:PolicyType>
            <provision:Status>1</provision:Status>
            <provision:PolicyKey>3769048351</provision:PolicyKey>
            <provision:Data>
                <provision:EASProvisionDoc>
                    <provision:DevicePasswordEnabled>1</provision:DevicePasswordEnabled>
                    <provision:AlphanumericDevicePasswordRequired>0</provision:AlphanumericDevicePasswordRequired>
                    <provision:PasswordRecoveryEnabled>0</provision:PasswordRecoveryEnabled>
                    <provision:RequireStorageCardEncryption>0</provision:RequireStorageCardEncryption>
                    <provision:AttachmentsEnabled>1</provision:AttachmentsEnabled>
                    <provision:MinDevicePasswordLength/>
                    <provision:MaxInactivityTimeDeviceLock>300</provision:MaxInactivityTimeDeviceLock>
                    <provision:MaxDevicePasswordFailedAttempts>5</provision:MaxDevicePasswordFailedAttempts>
                    <provision:MaxAttachmentSize/>
                    <provision:AllowSimpleDevicePassword>1</provision:AllowSimpleDevicePassword>
                    <provision:DevicePasswordExpiration/>
                    <provision:DevicePasswordHistory>0</provision:DevicePasswordHistory>
                    <provision:AllowStorageCard>1</provision:AllowStorageCard>
                    <provision:AllowCamera>1</provision:AllowCamera>
                    <provision:RequireDeviceEncryption>0</provision:RequireDeviceEncryption>
                    <provision:AllowUnsignedApplications>1</provision:AllowUnsignedApplications>
                    <provision:AllowUnsignedInstallationPackages>1</provision:AllowUnsignedInstallationPackages>
                    <provision:MinDevicePasswordComplexCharacters>3</provision:MinDevicePasswordComplexCharacters>
                    <provision:AllowWiFi>1</provision:AllowWiFi>
                    <provision:AllowTextMessaging>1</provision:AllowTextMessaging>
                    <provision:AllowPOPIMAPEmail>1</provision:AllowPOPIMAPEmail>
                    <provision:AllowBluetooth>2</provision:AllowBluetooth>
                    <provision:AllowIrDA>1</provision:AllowIrDA>
                    <provision:RequireManualSyncWhenRoaming>0</provision:RequireManualSyncWhenRoaming>
                    <provision:AllowDesktopSync>1</provision:AllowDesktopSync>
                    <provision:MaxCalendarAgeFilter>0</provision:MaxCalendarAgeFilter>
                    <provision:AllowHTMLEmail>1</provision:AllowHTMLEmail>
                    <provision:MaxEmailAgeFilter>0</provision:MaxEmailAgeFilter>
                    <provision:MaxEmailBodyTruncationSize>-1</provision:MaxEmailBodyTruncationSize>
                    <provision:MaxEmailHTMLBodyTruncationSize>-1</provision:MaxEmailHTMLBodyTruncationSize>
                    <provision:RequireSignedSMIMEMessages>0</provision:RequireSignedSMIMEMessages>
                    <provision:RequireEncryptedSMIMEMessages>0</provision:RequireEncryptedSMIMEMessages>
                    <provision:RequireSignedSMIMEAlgorithm>0</provision:RequireSignedSMIMEAlgorithm>
                    <provision:RequireEncryptionSMIMEAlgorithm>0</provision:RequireEncryptionSMIMEAlgorithm>
                    <provision:AllowSMIMEEncryptionAlgorithmNegotiation>2</provision:AllowSMIMEEncryptionAlgorithmNegotiation>
                    <provision:AllowSMIMESoftCerts>1</provision:AllowSMIMESoftCerts>
                    <provision:AllowBrowser>1</provision:AllowBrowser>
                    <provision:AllowConsumerEmail>1</provision:AllowConsumerEmail>
                    <provision:AllowRemoteDesktop>1</provision:AllowRemoteDesktop>
                    <provision:AllowInternetSharing>1</provision:AllowInternetSharing>
                    <provision:UnapprovedInROMApplicationList/>
                    <provision:ApprovedApplicationList/>
                </provision:EASProvisionDoc>
            </provision:Data>
        </provision:Policy>
    </provision:Policies>
</provision:Provision>

步骤2:第二条规定(意味着确认):

Request:
POST /Microsoft-Server-ActiveSync?User=user8&DeviceId=482049E2C44C47E38438410E418E9B02&DeviceType=iPhone&Cmd=Provision HTTP/1.1
Host: mail.blahtest.com
Content-Type: application/vnd.ms-sync.wbxml
X-MS-PolicyKey: 3769048351
Content-Length: 85
Cookie: X-BackEndCookie=S-1-5-21-1158204237-3780276595-2398335240-1113=u56Lnp2ejJqBm5nNx8bOyZ3Sz5ubyNLLns7G0saazszSzZudnJmcmsbHzszNgYHOztDOz9DNz87L38bFysfFy8nfr7I=
User-Agent: CS Mail/1.0.5 (iPhone Simulator; iOS 8.1; Scale/2.00)
MS-ASProtocolVersion: 14.1
Authorization: Basic <snip>
Accept-Encoding: gzip
<?xml version="1.0" encoding="utf-8"?>
<provision:Provision xmlns:provision="Provision:">
    <provision:Policies>
        <provision:Policy>
            <provision:PolicyType>MS-EAS-Provisioning-WBXML</provision:PolicyType>
            <provision:PolicyKey>3769048351</provision:PolicyKey>
            <provision:Status>1</provision:Status>
        </provision:Policy>
    </provision:Policies>
</provision:Provision>

Response:
HTTP/1.1 200 OK
Content-Type: application/vnd.ms-sync.wbxml
Content-Encoding: gzip
request-id: 3f9b10d1-2012-4df0-93c2-427cb37b8dfd
X-TargetBEServer: blahtest.blahtest.com
X-DiagInfo: blahtest
Set-Cookie: X-BackEndCookie=S-1-5-21-1158204237-3780276595-2398335240-1113=u56Lnp2ejJqBm5nNx8bOyZ3Sz5ubyNLLns7G0saazszSzZudnJmcmsbHzszNgYHOztDOz9DNz87L387Pxc/Nxc3K36+y; expires=Mon, 10-Nov-2014 22:02:25 GMT; path=/Microsoft-Server-ActiveSync; secure; HttpOnly
X-FEServer: blahtest
Date: Mon, 10 Nov 2014 21:52:25 GMT
Connection: close
Content-Length: 342

<?xml version="1.0"?>
<provision:Provision xmlns:airsync="AirSync" xmlns:provision="Provision" xmlns:settings="Settings">
    <settings:DeviceInformation>
        <settings:Status>1</settings:Status>
    </settings:DeviceInformation>
    <provision:Status>1</provision:Status>
    <provision:Policies>
        <provision:Policy>
            <provision:PolicyType>MS-EAS-Provisioning-WBXML</provision:PolicyType>
            <provision:Status>1</provision:Status>
            <provision:PolicyKey>3769048351</provision:PolicyKey>
            <provision:Data>
                <provision:EASProvisionDoc>
                    <provision:DevicePasswordEnabled>1</provision:DevicePasswordEnabled>
                    <provision:AlphanumericDevicePasswordRequired>0</provision:AlphanumericDevicePasswordRequired>
                    <provision:PasswordRecoveryEnabled>0</provision:PasswordRecoveryEnabled>
                    <provision:RequireStorageCardEncryption>0</provision:RequireStorageCardEncryption>
                    <provision:AttachmentsEnabled>1</provision:AttachmentsEnabled>
                    <provision:MinDevicePasswordLength/>
                    <provision:MaxInactivityTimeDeviceLock>300</provision:MaxInactivityTimeDeviceLock>
                    <provision:MaxDevicePasswordFailedAttempts>5</provision:MaxDevicePasswordFailedAttempts>
                    <provision:MaxAttachmentSize/>
                    <provision:AllowSimpleDevicePassword>1</provision:AllowSimpleDevicePassword>
                    <provision:DevicePasswordExpiration/>
                    <provision:DevicePasswordHistory>0</provision:DevicePasswordHistory>
                    <provision:AllowStorageCard>1</provision:AllowStorageCard>
                    <provision:AllowCamera>1</provision:AllowCamera>
                    <provision:RequireDeviceEncryption>0</provision:RequireDeviceEncryption>
                    <provision:AllowUnsignedApplications>1</provision:AllowUnsignedApplications>
                    <provision:AllowUnsignedInstallationPackages>1</provision:AllowUnsignedInstallationPackages>
                    <provision:MinDevicePasswordComplexCharacters>3</provision:MinDevicePasswordComplexCharacters>
                    <provision:AllowWiFi>1</provision:AllowWiFi>
                    <provision:AllowTextMessaging>1</provision:AllowTextMessaging>
                    <provision:AllowPOPIMAPEmail>1</provision:AllowPOPIMAPEmail>
                    <provision:AllowBluetooth>2</provision:AllowBluetooth>
                    <provision:AllowIrDA>1</provision:AllowIrDA>
                    <provision:RequireManualSyncWhenRoaming>0</provision:RequireManualSyncWhenRoaming>
                    <provision:AllowDesktopSync>1</provision:AllowDesktopSync>
                    <provision:MaxCalendarAgeFilter>0</provision:MaxCalendarAgeFilter>
                    <provision:AllowHTMLEmail>1</provision:AllowHTMLEmail>
                    <provision:MaxEmailAgeFilter>0</provision:MaxEmailAgeFilter>
                    <provision:MaxEmailBodyTruncationSize>-1</provision:MaxEmailBodyTruncationSize>
                    <provision:MaxEmailHTMLBodyTruncationSize>-1</provision:MaxEmailHTMLBodyTruncationSize>
                    <provision:RequireSignedSMIMEMessages>0</provision:RequireSignedSMIMEMessages>
                    <provision:RequireEncryptedSMIMEMessages>0</provision:RequireEncryptedSMIMEMessages>
                    <provision:RequireSignedSMIMEAlgorithm>0</provision:RequireSignedSMIMEAlgorithm>
                    <provision:RequireEncryptionSMIMEAlgorithm>0</provision:RequireEncryptionSMIMEAlgorithm>
                    <provision:AllowSMIMEEncryptionAlgorithmNegotiation>2</provision:AllowSMIMEEncryptionAlgorithmNegotiation>
                    <provision:AllowSMIMESoftCerts>1</provision:AllowSMIMESoftCerts>
                    <provision:AllowBrowser>1</provision:AllowBrowser>
                    <provision:AllowConsumerEmail>1</provision:AllowConsumerEmail>
                    <provision:AllowRemoteDesktop>1</provision:AllowRemoteDesktop>
                    <provision:AllowInternetSharing>1</provision:AllowInternetSharing>
                    <provision:UnapprovedInROMApplicationList/>
                    <provision:ApprovedApplicationList/>
                </provision:EASProvisionDoc>
            </provision:Data>
        </provision:Policy>
    </provision:Policies>
</provision:Provision>

步骤3(失败,状态为142):下一个命令,例如FolderSync:

Request:
POST /Microsoft-Server-ActiveSync?User=user8&DeviceId=482049E2C44C47E38438410E418E9B02&DeviceType=iPhone&Cmd=FolderSync HTTP/1.1
Host: mail.blahtest.com
Content-Type: application/vnd.ms-sync.wbxml
X-MS-PolicyKey: 3769048351
Content-Length: 13
Connection: close
Proxy-Connection: close
Cookie: X-BackEndCookie=S-1-5-21-1158204237-3780276595-2398335240-1113=u56Lnp2ejJqBm5nNx8bOyZ3Sz5ubyNLLns7G0saazszSzZudnJmcmsbHzszNgYHOztDOz9DNz87L387Pxc/Nxc3K36+y
User-Agent: CS Mail/1.0.5 (iPhone Simulator; iOS 8.1; Scale/2.00)
MS-ASProtocolVersion: 14.1
Authorization: Basic <snip>
Accept-Encoding: gzip

响应给出的状态为142(DeviceNotProvisioned)这让我相信承认没有正确发生。

我可能错了,但我认为第二个请求的X-MS-PolicyKey标头应该是:

X-MS-PolicyKey:0

我的代码中存在一个问题,即在帖子正文中没有正确设置PolicyKey。我现在开始工作了。

相关内容

  • 没有找到相关文章

最新更新