示例#1
0
        public NSPIAdapter(ITestSite site)
        {
            this.site = site;
            this.originalServerName = Common.GetConfigurationPropertyValue("SutComputerName", this.site);
            this.userName           = Common.GetConfigurationPropertyValue("AdminUserName", this.site);
            this.domainName         = Common.GetConfigurationPropertyValue("Domain", this.site);
            this.password           = Common.GetConfigurationPropertyValue("AdminUserPassword", this.site);
            this.waitTime           = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.site));
            this.maxRetryCount      = uint.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.site));
            string requestURL = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.site);

            requestURL              = Regex.Replace(requestURL, @"\[ServerName\]", this.originalServerName, RegexOptions.IgnoreCase);
            this.transport          = Common.GetConfigurationPropertyValue("TransportSeq", this.site).ToLower(System.Globalization.CultureInfo.CurrentCulture);
            AdapterHelper.Transport = this.transport;
            if (this.transport == "ncacn_http" || this.transport == "ncacn_ip_tcp")
            {
                this.InitializeRPC();
                this.nspiRpcAdapter = new NspiRpcAdapter(this.site, this.rpcBinding, this.contextHandle, this.waitTime, this.maxRetryCount);
            }
            else
            {
                AdapterHelper.SessionContextCookies = new CookieCollection();
                this.autoDiscoverProperties         = AutoDiscover.GetAutoDiscoverProperties(this.site, this.originalServerName, this.userName, this.domainName, requestURL, this.transport);
                this.site.Assert.IsNotNull(this.autoDiscoverProperties.AddressBookUrl, @"The auto discover process should return the URL to be used to connect with a NSPI server through MAPI over HTTP successfully.");
                this.nspiMapiHttpAdapter = new NspiMapiHttpAdapter(this.site, this.userName, this.password, this.domainName, this.autoDiscoverProperties.AddressBookUrl);
            }
        }
        /// <summary>
        /// Get the mailbox server endpoint URI and the address book server endpoint URI by Autodiscover.
        /// </summary>
        private void GetEndpointUrl()
        {
            string originalServerName = Common.GetConfigurationPropertyValue("SutComputerName", this.Site);
            string transportSequence  = Common.GetConfigurationPropertyValue("TransportSeq", this.Site);
            string requestURL         = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.Site);

            requestURL = Regex.Replace(requestURL, @"\[ServerName\]", originalServerName, RegexOptions.IgnoreCase);

            AutoDiscoverProperties autoDiscoverProperties = AutoDiscover.GetAutoDiscoverProperties(this.Site, originalServerName, this.userName, this.domainName, requestURL, transportSequence.ToLower());

            this.mailStoreUrl   = autoDiscoverProperties.PrivateMailStoreUrl;
            this.addressBookUrl = autoDiscoverProperties.AddressBookUrl;
        }
 /// <summary>
 /// Initializes the current adapter instance associated with a test site.
 /// </summary>
 /// <param name="testSite">The test site instance associated with the current adapter.</param>
 public override void Initialize(ITestSite testSite)
 {
     base.Initialize(testSite);
     testSite.DefaultProtocolDocShortName = "MS-OXNSPI";
     Common.MergeConfiguration(testSite);
     AdapterHelper.Site = testSite;
     if (bool.Parse(Common.GetConfigurationPropertyValue("MS-OXNSPI_Supported", this.Site)))
     {
         this.nspiRpcAdapter      = null;
         this.nspiMapiHttpAdapter = null;
         this.originalServerName  = Common.GetConfigurationPropertyValue("SutComputerName", this.Site);
         this.userName            = Common.GetConfigurationPropertyValue("User1Name", this.Site);
         this.Site.Assume.IsNotNull(this.userName, "The User1Name field in the ptfconfig file should not be null.");
         this.Site.Assume.IsNotNull(Common.GetConfigurationPropertyValue("User2Name", this.Site), "The User2Name field in the ptfconfig file should not be null.");
         this.Site.Assume.IsNotNull(Common.GetConfigurationPropertyValue("User3Name", this.Site), "The User3Name field in the ptfconfig file should not be null.");
         this.domainName = Common.GetConfigurationPropertyValue("Domain", this.Site);
         this.password   = Common.GetConfigurationPropertyValue("User1Password", this.Site);
         string publicFolderMailbox = Common.GetConfigurationPropertyValue("PublicFolderMailbox", this.Site);
         string requestURL          = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.Site);
         requestURL     = Regex.Replace(requestURL, @"\[ServerName\]", this.originalServerName, RegexOptions.IgnoreCase);
         this.transport = Common.GetConfigurationPropertyValue("TransportSeq", this.Site).ToLower(System.Globalization.CultureInfo.CurrentCulture);
         this.Site.Assert.IsTrue(this.transport == "mapi_http" || this.transport == "ncacn_http" || this.transport == "ncacn_ip_tcp", @"The TransportSeq field in the ptfconfig file must be set to one of the following three values: mapi_http, ncacn_http and ncacn_ip_tcp.");
         this.waitTime           = Convert.ToInt32(Common.GetConfigurationPropertyValue("WaitTime", testSite));
         this.maxRetryCount      = Convert.ToUInt32(Common.GetConfigurationPropertyValue("RetryCount", testSite));
         AdapterHelper.Transport = this.transport;
         if (this.transport == "ncacn_http" || this.transport == "ncacn_ip_tcp")
         {
             this.InitializeRPC();
             this.nspiRpcAdapter = new NspiRpcAdapter(this.Site, this.rpcBinding, this.contextHandle, this.waitTime, this.maxRetryCount);
         }
         else
         {
             AdapterHelper.SessionContextCookies = new CookieCollection();
             this.autoDiscoverProperties         = AutoDiscover.GetAutoDiscoverProperties(this.Site, this.originalServerName, this.userName, this.domainName, requestURL, this.transport, publicFolderMailbox);
             this.Site.Assert.IsNotNull(this.autoDiscoverProperties.AddressBookUrl, @"The auto discover process should return the URL to be used to connect with a NSPI server through MAPI over HTTP successfully.");
             this.nspiMapiHttpAdapter = new NspiMapiHttpAdapter(this.Site, this.userName, this.password, this.domainName, this.autoDiscoverProperties.AddressBookUrl);
         }
     }
 }