public uint Connect(string mailStoreUrl, string domain, string userName, string userDN, string password)
{
uint returnValue = 0;
this.domain = domain;
this.userPassword = password;
this.mailStoreUrl = mailStoreUrl;
this.userName = userName;
ConnectRequestBody connectBody = new ConnectRequestBody();
connectBody.UserDN = userDN;
// The server MUST NOT compress ROP response payload (rgbOut) or auxiliary payload (rgbAuxOut).
connectBody.Flags = 0x00000001;
// The code page in which text data is sent.
connectBody.Cpid = 1252;
// The local ID for everything other than sorting.
connectBody.LcidString = 0x00000409;
// The local ID for sorting.
connectBody.LcidSort = 0x00000409;
connectBody.AuxiliaryBufferSize = 0;
connectBody.AuxiliaryBuffer = new byte[] { };
if (this.cookies == null)
{
this.cookies = new CookieCollection();
}
HttpWebResponse response = SendMAPIHttpRequest(this.site, mailStoreUrl, userName, domain, password, connectBody, "Connect", this.cookies);
string transferEncoding = response.Headers["Transfer-Encoding"];
string pendingInterval = response.Headers["X-PendingPeriod"];
string responseCode = response.Headers["X-ResponseCode"];
if (transferEncoding != null)
{
if (string.Compare(transferEncoding, "chunked") == 0)
{
byte[] rawBuffer = ReadHttpResponse(response);
returnValue = uint.Parse(responseCode);
if (returnValue == 0)
{
ChunkedResponse chunkedResponse = ChunkedResponse.ParseChunkedResponse(rawBuffer);
ConnectSuccessResponseBody responseSuccess = ConnectSuccessResponseBody.Parse(chunkedResponse.ResponseBodyRawData);
}
else
{
this.site.Assert.Fail("Can't connect the server through MAPI over HTTP, the error code is: {0}", responseCode);
}
}
}
response.GetResponseStream().Close();
this.cookies = response.Cookies;
return returnValue;
}