public bool Connect(string server, ConnectionType connectionType, string userDN, string domain, string userName, string password)
{
this.privateMailboxServer = null;
this.privateMailboxProxyServer = null;
this.publicFolderServer = null;
this.publicFolderProxyServer = null;
this.privateMailStoreUrl = null;
this.publicFolderUrl = null;
this.userName = userName;
this.userDN = userDN;
this.userPassword = password;
this.domainName = domain;
this.originalServerName = server;
if ((this.MapiContext.AutoRedirect == true) && (Common.GetConfigurationPropertyValue("UseAutodiscover", this.site).ToLower() == "true"))
{
string requestURL = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.site);
requestURL = Regex.Replace(requestURL, @"\[ServerName\]", this.originalServerName, RegexOptions.IgnoreCase);
AutoDiscoverProperties autoDiscoverProperties = AutoDiscover.GetAutoDiscoverProperties(this.site, this.originalServerName, this.userName, this.domainName, requestURL, this.MapiContext.TransportSequence.ToLower());
this.privateMailboxServer = autoDiscoverProperties.PrivateMailboxServer;
this.privateMailboxProxyServer = autoDiscoverProperties.PrivateMailboxProxy;
this.publicFolderServer = autoDiscoverProperties.PublicMailboxServer;
this.publicFolderProxyServer = autoDiscoverProperties.PublicMailboxProxy;
this.privateMailStoreUrl = autoDiscoverProperties.PrivateMailStoreUrl;
this.publicFolderUrl = autoDiscoverProperties.PublicMailStoreUrl;
}
else
{
if (this.MapiContext.TransportSequence.ToLower() == "mapi_http")
{
this.site.Assert.Fail("When the value of TransportSeq is set to mapi_http, the value of UseAutodiscover must be set to true.");
}
else
{
this.publicFolderServer = server;
this.privateMailboxServer = server;
}
}
bool ret = false;
switch (this.MapiContext.TransportSequence.ToLower())
{
case "mapi_http":
if (connectionType == ConnectionType.PrivateMailboxServer)
{
ret = this.MapiConnect(this.privateMailStoreUrl, userDN, domain, userName, password);
}
else
{
ret = this.MapiConnect(this.publicFolderUrl, userDN, domain, userName, password);
}
break;
case "ncacn_ip_tcp":
case "ncacn_http":
if (connectionType == ConnectionType.PrivateMailboxServer)
{
ret = this.RpcConnect(this.privateMailboxServer, userDN, domain, userName, password, this.privateMailboxProxyServer);
}
else
{
ret = this.RpcConnect(this.publicFolderServer, userDN, domain, userName, password, this.publicFolderProxyServer);
}
break;
default:
this.site.Assert.Fail("TransportSeq \"{0}\" is not supported by the test suite.");
break;
}
return ret;
}