Example #1
0
        /// <summary>
        /// This method will return the Server Information object
        /// </summary>
        public static LdapServerInformation RetrieveSettings()
        {
            LdapServerInformation info = new LdapServerInformation();
            info.ReadFromRegistry();

            if (string.IsNullOrEmpty(info.Context) && string.IsNullOrEmpty(info.ServerName))
            {
                Logger.LogInfo(ResourceManager.GetString("NO_SERVERS", "Workshare.DirectorySearcher.Exceptions", typeof(Detector).Assembly));
                throw (new LdapException(new ExceptionResource("SETTINGMISS", "Workshare.DirectorySearcher.Exceptions", typeof(Detector).Assembly)));
            }

            return info;
        }
        public void Test_01_ReadFromRegistry()
        {
            Test_Helper.SetValuesInRegistry("testServer", 3, "testContext", "testUser", "testPassword");

            LdapServerInformation cut = new LdapServerInformation();
            Assert.IsTrue(cut.ReadFromRegistry());

            Assert.AreEqual("testServer", cut.ServerName);
            Assert.AreEqual(3, cut.Port);
            Assert.AreEqual("testContext", cut.Context);
            Assert.AreEqual("testUser", cut.UserName);
            Assert.AreEqual("testPassword", cut.Password);                
        }