示例#1
0
        public ServerEditor(LdapServerInformation server)
        {
            InitializeComponent();

            m_server = server;
            UpdateUi();
        }
示例#2
0
        /// <summary>
        /// Will validate the inputs from the GetEngine Methods
        /// </summary>
        /// <param name="server">The server object to use</param>
        private static void ValidateInput(LdapServerInformation server)
        {
            if (server == null)
            {
				Logger.LogInfo(ResourceManager.GetString("NO_SERVER", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly));
                throw (new LdapException(new ExceptionResource("SETTINGMISS", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly)));
            }
            if ((server.Port < 0 || server.Port > 65536))
            {
				Logger.LogInfo(ResourceManager.GetString("INVALIDPORT", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly));
                throw (new LdapException(new ExceptionResource("INVALIDPORT", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly)));
            }

            if (server.ServerName == null || (server.ServerName.Length == 0 && server.Context.Length == 0))
            {
				Logger.LogInfo(ResourceManager.GetString("NO_SERVER", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly));
                throw (new LdapException(new ExceptionResource("INVALIDSERV", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly)));
            }

            // Check that the context should be an empty string.
            if (server.Context == null)
            {
				Logger.LogInfo(ResourceManager.GetString("CONTEXT_EMPTY", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly));
                server.Context  = "";
            }
        }
 /// <summary>
 /// This is the default constructor used to initialise the internal 
 /// members and make sure that the server is assigned.
 /// </summary>
 /// <param name="server">The server object to be used for this instance of the engine</param>
 public ActiveDirectoryEngine(LdapServerInformation server)
     :base(server)
 {
     DefaultClass = "user";
     Properties.AddRange(new string[]{ "cn", "mail", "adspath", "uid", "objectclass", "legacyexchangedn"});
     DefaultSearch = "(&(|(objectClass={0})(objectClass=Group))({1}))";
     OrginalContext = server.Context;
 }
示例#4
0
 /// <summary>
 /// This is the default constructor used to initialise the internal 
 /// members and make sure that the server is assigned.
 /// </summary>
 /// <param name="server">The server object to be used for this instance of the engine</param>
 public NovellEngine(LdapServerInformation server)
     : base(server)
 {
     DefaultClass = "person";
     Properties.AddRange(new string[] { "cn", "mail", "adspath", "uid", "objectclass" });
     DefaultSearch = "(&(|(objectClass={0})(objectClass=groupofnames))({1}))";
     OrginalContext = server.Context;
     PageSize = 0;
 }
示例#5
0
 /// <summary>
 /// This is the default constructor used to initialise the internal 
 /// members and make sure that the server is assigned.
 /// </summary>
 /// <param name="server">The server object to be used for this instance of the engine</param>
 public DominoEngine(LdapServerInformation server)
     : base(server)
 {
     DefaultClass = "dominoPerson";
     Properties.AddRange(new string[] { "cn", "mail", "adspath", "uid", "objectclass" });
     DefaultSearch = "(&(|(objectClass={0})(objectClass=dominoGroup))({1}))";
     PageSize = 0; // Cannot set this value for Domino Server!
     OrginalContext = server.Context;
 }
示例#6
0
        /// <summary>
        /// This constructor will hide the base constructor
        /// </summary>
        protected BaseEngine(LdapServerInformation server)
        {
            if (server == null)
            {
				Logger.LogInfo(ResourceManager.GetString("NO_SERVER", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly));
                throw (new LdapException(new ExceptionResource("SETTINGMISS", "Workshare.DirectorySearcher.Exceptions", typeof(BaseEngine).Assembly)));
            }
            m_server = server;
            m_pageSize = 100;
            m_isEnabled = true;
            m_properties = new List<string>();
        }
        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);                
        }
示例#8
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;
        }
示例#9
0
        /// <summary>
        /// This is the actual constructor called from the program
        /// </summary>
        /// <param name="server"></param>
        public Console(LdapServerInformation server)
        {
            m_first = true;
            if (server == null)
            {
				Logger.LogInfo(ResourceManager.GetString("NO_SERVER", "Workshare.DirectorySearcher.Exceptions", typeof(Console).Assembly));
                throw (new LdapException(new ExceptionResource("SETTINGMISS", "Workshare.DirectorySearcher.Exceptions", typeof(Console).Assembly)));
            }
            m_server = server;
            InitializeComponent();
            m_trace = new TextTraceListener(txtResults);
            System.Diagnostics.Trace.Listeners.Add(m_trace);
        }
        public void Test_02_SaveToRegistry()
        {
            Test_Helper.SetValuesInRegistry("", 0, "", "", "");

            LdapServerInformation cut = new LdapServerInformation();
            cut.ServerName = "testServer";
            cut.Port = 3;
            cut.Context = "testContext";
            cut.UserName = "******";
            cut.Password = "******";
            cut.KeyString = LdapServerInformation.DEFAULTREGKEY;
            Assert.IsTrue(cut.SaveToRegistry());

            ServerInfo confirm = Test_Helper.GetValuesFromRegistry();
            Assert.AreEqual("testServer", confirm.ServerName);
            Assert.AreEqual(3, confirm.Port);
            Assert.AreEqual("testContext", confirm.Context);
            Assert.AreEqual("testUser", confirm.UserName);
            Assert.AreEqual("testPassword", confirm.Password);
        }
示例#11
0
        /// <summary>
        /// Sets the m_engine member to an IEngine implementation
        /// </summary>
        /// <param name="ls">LDAP server information</param>
        private void GetEngine(LdapServerInformation ls)
        {
            try
            {
                m_creationInfo = ls;
                if (m_creationInfo == null)
                {
                    //  ls was null - retrieve info from the directory analyzers
                    //m_creationInfo = Detector.RetrieveSettings();
                    if (DirectoryAnalyzers.Instance.Analyzers.Count > 0)
                    {
                        m_creationInfo = DirectoryAnalyzers.Instance.Analyzers[0].LdapServer;
                    }
                    
                    if (m_creationInfo == null)
                    {
                        m_creationInfo = new LdapServerInformation();
                    }
                }

                m_engine = Detector.GetEngine(m_creationInfo);
                if (m_engine != null)
                    m_isAvailable = m_engine.IsEnabled;
            }
            catch (InvalidOperationException e)
            {
                // Cannot connect to Ldap so will ignore it.
				Logger.LogError(e);
            }
            catch (LdapException e)
            {
                //ignore it as we do want something.
                //Is LDAP Available will be false!
				Logger.LogError(e);
            }
        }
示例#12
0
        /// <summary>
        /// Returns the implementation of the LDAP engine for a given server
        /// </summary>
        /// <param name="ls">LDAP server information</param>
        /// <returns>The LDAP engine to use. Null if server name or LDAP engine is not valid</returns>
        /// <exception cref="LdapException">If either the server name or port is invalid</exception>
        public static IEngine GetEngine(LdapServerInformation ls)
        {
            IEngine eng = null;

            if (string.IsNullOrEmpty(ls.Context) && string.IsNullOrEmpty(ls.ServerName))
                return eng;


            if (CheckServerAvailable(ls.ServerName) == false && !string.IsNullOrEmpty(ls.Context))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(ResourceManager.GetString("CONTEXT_USED",
                            "Workshare.DirectorySearcher.Exceptions", typeof(Detector).Assembly), ls.Context);
				Logger.LogInfo(sb.ToString());
            }
            DirectoryEntry root = BaseEngine.GetRootServer(ls);

            switch (ls.LdapType)
            {
                case EngineType.ActiveDirectory:
                    eng = new ActiveDirectoryEngine(ls);
                    break;
                case EngineType.Domino:
                    eng = new DominoEngine(ls);
                    break;
                case EngineType.Novell:
                    eng = new NovellEngine(ls);
                    break;
            }
            return new CachingEngine(eng);
        }
示例#13
0
 public void ChangeServerInformation(LdapServerInformation ls)
 {
     m_impl = new DirectoryAnalyzerImpl(ls);
 }
示例#14
0
 public DirectoryAnalyzer(LdapServerInformation ls)
 {
     m_impl = new DirectoryAnalyzerImpl(ls);
 }
        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;
            }
        }
示例#16
0
        public object Clone()
        {
            LdapServerInformation clone = new LdapServerInformation();

            clone.m_serverName = m_serverName;
            clone.m_port = m_port;
            clone.m_context = m_context;
            clone.m_userName = m_userName;
            clone.m_password = m_password;
            clone.m_type = m_type;
            clone.m_keyString = m_keyString;

            return clone;
        }
示例#17
0
 /// <summary>
 /// This method will get the root server context.  If user name is not specified then it will use the
 /// trusted connection informaton.
 /// </summary>
 /// <param name="server">The server information to be used</param>
 /// <returns>The root ADS object.  NULL not found</returns>
 /// <exception cref="LdapException">If either the server name is invalid</exception>
 public static DirectoryEntry GetRootServer(LdapServerInformation server)
 {
     ValidateInput(server);
     return GetEntry(server, AuthenticationTypes.None);
 }
示例#18
0
 protected static DirectoryEntry GetEntry(LdapServerInformation server, AuthenticationTypes type)
 {
     return server.GetEntry(type);
 }
示例#19
0
 public ServerSetup()
 {
     InitializeComponent();
     m_server = new LdapServerInformation();
 }
示例#20
0
 public static void LdapInfoToPolicyObject(IPolicyObject policyObj, LdapServerInformation info)
 {
     SetPropertyIfNotNullOrEmpty(policyObj, LDAPRouter.SERVERNAMEPROPERTY, info.ServerName);
     SetPropertyIfNotNullOrEmpty(policyObj, LDAPRouter.CONTEXTPROPERTY, info.Context);
     SetPropertyIfNotNullOrEmpty(policyObj, LDAPRouter.PORTPROPERTY, info.Port.ToString(CultureInfo.InvariantCulture));
     SetPropertyIfNotNullOrEmpty(policyObj, LDAPRouter.USERNAMEPROPERTY, info.UserName);
     SetPropertyIfNotNullOrEmpty(policyObj, LDAPRouter.PASSWORDPROPERTY, info.Password);
 }
示例#21
0
 /// <summary>
 /// Setup constructor to initialise the internal members. Creates the LDAP engine from supplied server information
 /// </summary>
 /// <param name="ls">LDAP server information</param>
 public DirectoryAnalyzerImpl(LdapServerInformation ls)
 {
     GetEngine(ls);
 }