예제 #1
0
        public void Read(System.Xml.XmlNode node)
        {
            string serverName = GetAttribute(node, SERVERNAMEPROPERTY);
            string context = GetAttribute(node, CONTEXTPROPERTY);
            string userName = GetAttribute(node, USERNAMEPROPERTY);
            string password = GetAttribute(node, PASSWORDPROPERTY);
            string port = GetAttribute(node, PORTPROPERTY);

            int portNum = (string.IsNullOrEmpty(port) ? 0 : int.Parse(port, CultureInfo.CurrentCulture));

            // If there's no information to speak of here, then use the default analyzer (this is to support legacy router setup)
            if (string.IsNullOrEmpty(context) && string.IsNullOrEmpty(serverName))
            {
                m_directoryAnalyzer = DirectoryAnalyzers.Instance.DefaultAnalyzer;
                // If the analyzer is still null (policy somehow contained empty router setup), then just set up with a dummy analyzer
                if (m_directoryAnalyzer == null)
                {
                    m_directoryAnalyzer = new DirectoryAnalyzer();
                }
            }
            else
            {
                m_directoryAnalyzer = DirectoryAnalyzers.Instance.FindOrCreateAnalyzer(serverName, portNum, context, userName, password, false);
            }
        }
 public void Test_04_AddressRange()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     string[] emails = { "*****@*****.**", "*****@*****.**" };
     IAddressCollection ac = da.GetAddressCollectionInformation(emails);
     Assert.IsTrue(ac.Count == 2, "The number of emails does not match");
     Assert.AreEqual(ac["*****@*****.**"].DisplayName, "DevBuild", "The display names are not the same");
     Assert.AreEqual(ac["*****@*****.**"].DisplayName, "Internal1", "The display names are not the same");
 }
 public void Test_01_CreateDominoEngine()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     Assert.IsNotNull(da, "The Directory Analyzer is null therefore will fail!");
     Assert.IsTrue(da.IsLdapAvailable, "The LDAP Engine is not available");
     Assert.IsTrue(da.IsLdapEnabled, "The LDAP Engine is not enabled");
     Assert.IsTrue((da.LdapType == EngineType.Domino), "The LDAP Engine is not Domino");
     Assert.AreEqual(da.LdapServer.ServerName, "10.10.3.115", "The Server names are not the same");
 }
 public void Test_01_CreateActiveDirectoryEngine()
 {
     Test_Helper.SetupWsQADomain();
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
 
     Assert.IsNotNull(da, "The Directory Analyzer is null therefore will fail!");
     Assert.IsTrue(da.IsLdapAvailable, "The LDAP Engine is not available");
     Assert.IsTrue(da.IsLdapEnabled, "The LDAP Engine is not enabled");
     Assert.IsTrue((da.LdapType == EngineType.ActiveDirectory), "The LDAP Engine is not Active Directory");
     Assert.AreEqual(da.LdapServer.ServerName, "", "The Server names are not the same");
 }
        public void Test_04_AddressRange()
        {
            Test_Helper.SetupWsQADomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            string[] emails = { "*****@*****.**", "*****@*****.**" };
            IAddressCollection ac = da.GetAddressCollectionInformation(emails);
            
            Assert.IsTrue(ac.Count == 2, "The number of emails does not match");
            Assert.AreEqual(ac["*****@*****.**"].DisplayName, "qa1", "The display names are not the same");
            Assert.AreEqual(ac["*****@*****.**"].DisplayName, "QA Admin", "The display names are not the same");
        }
 public void Test_02_RetrieveSmtpEmailAddress()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     Assert.IsNotNull(da, "The Directory Analyzer is null therefore will fail!");
     Assert.IsTrue(da.IsLdapAvailable, "The LDAP Engine is not available");
     Assert.IsTrue(da.IsLdapEnabled, "The LDAP Engine is not enabled");
 
     IAddress adr = da.GetAddressInformation("*****@*****.**");
     Assert.IsTrue((adr.AddressType == AddressType.Smtp), "The Address type is not the same");
     Assert.AreEqual(adr.DisplayName, "DevBuild", "The display names are not the same");
     Assert.AreEqual(adr.Email, "*****@*****.**", "The email address are not the same");
     Assert.AreEqual(adr.LdapPath, "CN=DevBuild,OU=Engineering,O=Workshare,C=ZA", "The Ldap address are different");
 }
        public void Test_03_RetrieveLdapAddress()
        {
            Test_Helper.SetupWsQADomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);
        
            Assert.IsNotNull(da, "The Directory Analyzer is null therefore will fail!");
            Assert.IsTrue(da.IsLdapAvailable, "The LDAP Engine is not available");
            Assert.IsTrue(da.IsLdapEnabled, "The LDAP Engine is not enabled");

            IAddress adr = da.GetAddressInformation("CN=qa1,DC=wsqa,DC=net");
            Assert.IsTrue((adr.AddressType == AddressType.Smtp), "The Address type is not the same");
            Assert.AreEqual(adr.DisplayName, "qa1", "The display names are not the same");
        }
 public void Test_02_RetrieveSmtpEmailAddress()
 {
     Test_Helper.SetupWsQADomain();
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     
     Assert.IsNotNull(da, "The Directory Analyzer is null therefore will fail!");
     Assert.IsTrue(da.IsLdapAvailable, "The LDAP Engine is not available");
     Assert.IsTrue(da.IsLdapEnabled, "The LDAP Engine is not enabled");
     
     IAddress adr = da.GetAddressInformation("*****@*****.**");
     Assert.IsTrue((adr.AddressType == AddressType.Smtp), "The Address type is not the same");
     Assert.AreEqual(adr.DisplayName, "qa1", "The display names are not the same");
     Assert.AreEqual(adr.Email, "*****@*****.**", "The email address are not the same");
     Assert.AreEqual(adr.LdapPath, "CN=qa1,OU=Users,OU=QA Accounts,OU=LN QA,OU=QA Control,DC=wsqa,DC=net", "The Ldap address are different");
 }
        public void Test_03_RetrieveLdapAddress()
        {
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);
            Assert.IsNotNull(da, "The Directory Analyzer is null therefore will fail!");
            Assert.IsTrue(da.IsLdapAvailable, "The LDAP Engine is not available");
            Assert.IsTrue(da.IsLdapEnabled, "The LDAP Engine is not enabled");
            
            IAddress adr = da.GetAddressInformation("CN=DevBuild,OU=Engineering,O=Workshare,C=ZA");
            Assert.IsTrue((adr.AddressType == AddressType.Smtp), "The Address type is not the same");
            Assert.AreEqual(adr.DisplayName, "DevBuild", "The display names are not the same");

            adr = da.GetAddressInformation("CN=Internal2/OU=Engineering/O=Workshare/C=ZA");
            Assert.IsTrue((adr.AddressType == AddressType.Smtp), "The Address type is not the same");
            Assert.AreEqual(adr.DisplayName, "Internal2", "The display names are not the same");

        }
        private void PopulateLdapServerList(DirectoryAnalyzer select)
        {
            ldapServerCombo.Items.Clear();
            foreach (DirectoryAnalyzer analyzer in DirectoryAnalyzers.Instance.Analyzers)
            {
                ldapServerCombo.Items.Add(analyzer);
            }
            ldapServerCombo.Items.Add("Create new server...");

            if (select != null)
            {
                ldapServerCombo.SelectedItem = select;
            }
            else
            {
                ldapServerCombo.SelectedIndex = 0; // this selects "Create new server..." as the initial item
            }
            UpdateSelectedServer();
        }
        public void Test_10_X500Address()
        {
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);
            
            IAddress smtp = da.GetAddressInformation("*****@*****.**");
            IAddress x500Comma = da.GetAddressInformation("CN=DevBuild,OU=Engineering,O=Workshare,C=ZA");
            IAddress x500ForwardSlash = da.GetAddressInformation("CN=DevBuild/OU=Engineering/O=Workshare/C=ZA");

            Assert.IsTrue(smtp.Email == x500Comma.Email);
            Assert.IsTrue(smtp.Email == x500ForwardSlash.Email);
        }
 public void Test_09_CaseInsensitive()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     string[] emails = {"*****@*****.**", "*****@*****.**"  };
     
     IAddressCollection addrs = da.GetAddressCollectionInformation(emails);
     string[] policyList = { "*****@*****.**", "*****@*****.**", "*****@*****.**" };
     IAddressCollection policies = da.GetAddressCollectionInformation(policyList);
     Assert.IsTrue(da.IsMemberOf(addrs, policies), "The emails are failing when they should not!");
 }
 public void Test_08_WildCardCheck_Fail()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     string[] emails = { "*****@*****.**", "*****@*****.**" };
     IAddressCollection addrs = da.GetAddressCollectionInformation(emails);
     string[] policyList = { "*@workshare.com" };
     IAddressCollection policies = da.GetAddressCollectionInformation(policyList);
     Assert.IsFalse(da.IsMemberOf(addrs, policies), "The emails are not failing when they should!");
 }
        public void Test_13_Everyone_Pass()
        {
            Test_Helper.SetupWsDevDomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            string[] emails = { "*****@*****.**" };
            IAddressCollection addrs = da.GetAddressCollectionInformation(emails);

            string[] policyList = { "*****@*****.**" };
            IAddressCollection policies = da.GetAddressCollectionInformation(policyList);

            Assert.IsTrue(da.IsMemberOf(addrs, policies), "The emails are failing when they should not!");
        }
        public void Test_18_ServerNotWorkingValidAddresses()
        {
            Test_Helper.SetupNonWorkingDomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            Assert.IsFalse(da.IsLdapAvailable, "LDAP should not be available, the server settings are deliberately wrong.");

            string[] emails = { "*****@*****.**", "*****@*****.**" };
            IAddressCollection ac = da.GetAddressCollectionInformation(emails);

            Assert.IsTrue(ac.Count == 2, "The number of emails does not match");
        }
 public void Test_13_GetGroupByName()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     IAddressCollection name = da.GetAddressCollectionInformation("External", FieldType.Name);
     Assert.IsTrue(name.Count > 0, "The number of members found is not as expected!");
 }
        public void Test_16_TestFindGroupByName()
        {
            Test_Helper.SetupWsDevDomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            IAddressCollection addrs = da.GetAddressCollectionInformation("InternalServerDistributionList", FieldType.Name);

            Assert.IsNotNull(addrs, "Should return a non-null IAddressCollection");
            Assert.IsTrue(addrs.Count == 1, "Should have returned exactly one IAddress matching the search");
        }
		public void Test_DisabledAccountsNOTPickedUp()
		{
			Test_Helper.SetupWsDevDomain();
			DirectoryAnalyzer da = new DirectoryAnalyzer(true);

			IAddress addr = da.GetUserDN("disableuser");
			Assert.IsNull(addr);
		}
		public void Test_GetCurrentUserDN()
		{
			Test_Helper.SetupWsDevDomain();
			DirectoryAnalyzer da = new DirectoryAnalyzer(true);

			IAddress addr = da.GetUserDN("lnpair");
			Assert.IsNotNull(addr);
			Assert.AreEqual(AddressUtils.GetAddressType(addr.LdapPath), AddressType.X500);
		}
        public void Test_11_X500ADGroupAddress()
        {
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);
            IAddress i1 = da.GetAddressInformation("cn=Group 1");
            Assert.IsTrue(i1.Email == "*****@*****.**", "i1 does not equal email!");

            IAddress i2 = da.GetAddressInformation("CN=Internal1,OU=Engineering,O=Workshare,C=ZA");
            Assert.IsTrue(da.IsMemberOf(i2, i1), "Internal1 is a not a member when it should be!");

            IAddress i3 = da.GetAddressInformation("CN=Internal2/OU=Engineering/O=Workshare/C=ZA");
            Assert.IsTrue(da.IsMemberOf(i3, i1), "Internal2 is a not a member when it should be!");

        }
 public void Test_12_GetMemberByField()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     IAddressCollection smtp = da.GetAddressCollectionInformation("*****@*****.**", FieldType.SmtpEmail);
     Assert.IsTrue(smtp.Count > 0, "The number of members found is not as expected!");
     
     IAddressCollection smptf = da.GetAddressCollectionInformation("pairjjjjjj", FieldType.SmtpEmail);
     Assert.IsTrue(smptf.Count == 0, "The number of members found should be zero!");
     
     IAddressCollection x500 = da.GetAddressCollectionInformation("Internal1", FieldType.X500Email);
     Assert.IsTrue(x500.Count > 0, "The number of members found is not as expected!");
     
     IAddressCollection name = da.GetAddressCollectionInformation("internal1", FieldType.Name);
     Assert.IsTrue(name.Count > 0, "The number of members found is not as expected!");
 }
        public void Test_15_GetNotFound()
        {
            Test_Helper.SetupWsDevDomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            string[] emails = { "*****@*****.**", "*****@*****.**" };
            IAddressCollection addrs = da.GetAddressCollectionInformation(emails);

            string[] policyList = { "*****@*****.**" };
            IAddressCollection policies = da.GetAddressCollectionInformation(policyList);
            
            addrs.ContainMembersOf(policies);
            string[] notFound = addrs.GetAddresses(false);
            Assert.IsTrue(notFound.Length == 1, "The number of not found is not correct!");
        }
        public void Test_14_WSDevDomain()
        {
            Test_Helper.SetupWsDevDomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);
            
            string email =  "/o=WSDEV/ou=First Administrative Group/cn=Recipients/cn=lnpair";
            IAddress addr = da.GetAddressInformation(email);

            Assert.IsTrue(addr.AddressType == AddressType.Smtp, "The email address type is not correct!");
        }
        public void Test_17_ServerNotWorkingValidAddress()
        {
            Test_Helper.SetupNonWorkingDomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            Assert.IsFalse(da.IsLdapAvailable, "LDAP should not be available, the server settings are deliberately wrong.");

            IAddress addr = da.GetAddressInformation("*****@*****.**");
            Assert.IsTrue(addr.AddressType == AddressType.Smtp, "It not a valid SMTP Address!");
            Assert.AreEqual(addr.Email, "*****@*****.**", "Address not the same");
        }
 public void Test_05_SimpleCheck_Pass()
 {
     Test_Helper.SetupWsQADomain();
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
 
     string[] emails = { "*****@*****.**", "*****@*****.**" };
     IAddressCollection addrs = da.GetAddressCollectionInformation(emails);
     
     string[] policyList = { "*****@*****.**", "*****@*****.**"};
     IAddressCollection policies = da.GetAddressCollectionInformation(policyList);
     
     Assert.IsTrue(da.IsMemberOf(addrs, policies), "The emails are failing when they should not!");
 }
        public void Initialise(IRoutingItemCollection routingItems)
        {
            //  Convert the routing item collection to an LdapServerInformation object, and try and find an appropriate directory analyzer
            //  that matches that information
            LdapServerInformation ls = RoutingHelper.PolicyObjectToLdapInfo(routingItems);
            DirectoryAnalyzer routingAnalyzer = DirectoryAnalyzers.Instance.FindAnalyzer(ls);

            //  If no matching directory analyzer can be found, then what's probably happened is that the policy has been loaded on
            //  a different box, or the registry has been manually abused. Persist the LdapServerInformation to the registry and
            //  create a new DirectoryAnalyzer from it
            if (routingAnalyzer == null)
            {
                ls.SaveToRegistry();
                routingAnalyzer = new DirectoryAnalyzer(ls);
                DirectoryAnalyzers.Instance.Add(routingAnalyzer);
            }

            PopulateLdapServerList(routingAnalyzer);

			StringBuilder sb = new StringBuilder();
			foreach (Policy.ObjectModel.IRoutingItem routingItem in routingItems)
			{
				sb.AppendFormat("{0};", routingItem.Content);
			}
			GroupMembers = sb.ToString();
        }
 public void Test_05_SimpleCheck_Pass()
 {
     DirectoryAnalyzer da = new DirectoryAnalyzer(true);
     string[] emails = { "*****@*****.**", "*****@*****.**" };
     IAddressCollection addrs = da.GetAddressCollectionInformation(emails);
     string[] policyList = { "*****@*****.**", "*****@*****.**", "*****@*****.**" };
     IAddressCollection policies = da.GetAddressCollectionInformation(policyList);
     Assert.IsTrue(da.IsMemberOf(addrs, policies), "The emails are failing when they should not!");
 }
        private void CreateNewServer()
        {
            LdapServerInformation ls = new LdapServerInformation();

            ServerEditor setupDlg = new ServerEditor(ls);
            if (setupDlg.ShowDialog() == DialogResult.OK)
            {
                ls.SaveToRegistry();

                //  Add the new analyzer to the analyzer list
                DirectoryAnalyzer newAnalyzer = new DirectoryAnalyzer(ls);
                DirectoryAnalyzers.Instance.Add(newAnalyzer);

                //  Add the new analyzer to the combo box, and select it
                ldapServerCombo.Items.Insert(0, newAnalyzer);
                ldapServerCombo.SelectedIndex = 0;
            }
        }
예제 #29
0
 public static void DirectoryAnalyzerToPolicyObject(IPolicyObject policyObj, DirectoryAnalyzer analyzer)
 {
     LdapInfoToPolicyObject(policyObj, analyzer.CreationInfo);
 }
        public void Test_12_GetMemberByField()
        {
            Test_Helper.SetupWsQADomain();
            DirectoryAnalyzer da = new DirectoryAnalyzer(true);

            IAddressCollection smtp = da.GetAddressCollectionInformation("*****@*****.**", FieldType.SmtpEmail);
            Assert.IsTrue(smtp.Count > 0, "The number of members found is not as expected!");

            IAddressCollection invalidSmtp = da.GetAddressCollectionInformation("phantom", FieldType.SmtpEmail);
            Assert.IsTrue(invalidSmtp.Count == 0, "The number of members found should be zero!");

            IAddressCollection x500 = da.GetAddressCollectionInformation("qaadmin1", FieldType.X500Email);
            Assert.IsTrue(x500.Count > 0, "The number of members found is not as expected!");

            IAddressCollection name = da.GetAddressCollectionInformation("qaadmin1", FieldType.Name);
            Assert.IsTrue(name.Count > 0, "The number of members found is not as expected!");
        }