/// <summary>
 /// Adds all the "user"/"group" objects to the tree
 /// </summary>
 /// <param name="container"></param>
 /// <param name="parentPage"></param>
 /// <param name="plugin"></param>
 /// <param name="PageType"></param>
 public AddUsertoGroup(IPlugInContainer container, MPPage parentPage, ADUCPlugin plugin, int PageType)
 : this()
 {
     this.IPlugInContainer = container;
     _addplugin = plugin;
     _aducRootnode = _addplugin.GetPlugInNode();
     _PageType = PageType;
     
     if (_aducRootnode.Nodes.Count > 0)
     {
         ADUCDirectoryNode rootNode =
         ADUCDirectoryNode.GetDirectoryRoot(_addplugin.GetpluginContext(),            
         _addplugin.GetRootDN(),
         Resources.ADUC, typeof (ADUCPage), _addplugin);
         
         if (rootNode != null)
         {
             treeView1.Nodes.Add(rootNode);
             rootNode.Refresh();
             treeView1.ExpandAll();
         }
     }
     else
     {
         Logger.Log("The LWTreeView control does not have any nodes.");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Adds all the "user"/"group" objects to the tree
        /// </summary>
        /// <param name="container"></param>
        /// <param name="parentPage"></param>
        /// <param name="plugin"></param>
        /// <param name="PageType"></param>
        public AddUsertoGroup(IPlugInContainer container, MPPage parentPage, ADUCPlugin plugin, int PageType)
            : this()
        {
            this.IPlugInContainer = container;
            _addplugin            = plugin;
            _aducRootnode         = _addplugin.GetPlugInNode();
            _PageType             = PageType;

            if (_aducRootnode.Nodes.Count > 0)
            {
                ADUCDirectoryNode rootNode =
                    ADUCDirectoryNode.GetDirectoryRoot(_addplugin.GetpluginContext(),
                                                       _addplugin.GetRootDN(),
                                                       Resources.ADUC, typeof(ADUCPage), _addplugin);

                if (rootNode != null)
                {
                    treeView1.Nodes.Add(rootNode);
                    rootNode.Refresh();
                    treeView1.ExpandAll();
                }
            }
            else
            {
                Logger.Log("The LWTreeView control does not have any nodes.");
            }
        }
 public DomainPropertiesDlg(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin)
     : base(container, parentPage)
 {
     InitializeComponent();
     this.Text = "{0} Properties";
     _plugin = plugin;
     _container = container;
     InitializePages();
 }
Beispiel #4
0
 public ADOUPropertiesDlg(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin)
     : base(container, parentPage)
 {
     InitializeComponent();
     Text       = "{0} Properties";
     _plugin    = plugin;
     _container = container;
     InitializePages();
 }
 public MultiItemPropertiesDlg(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin,
                               List <object> ObjectCounts)
     : base(container, parentPage)
 {
     InitializeComponent();
     this.ObjectCounts = ObjectCounts;
     _plugin           = plugin;
     _container        = container;
     InitializePages();
 }
 public MultiItemPropertiesDlg(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin,
                               List<object> ObjectCounts)
     : base(container, parentPage)
 {
     InitializeComponent();
     this.ObjectCounts = ObjectCounts;
     _plugin = plugin;
     _container = container;
     InitializePages();
 }
 public ADGroupPropertiesDlg(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin, ADUCDirectoryNode dirnode)
     : base(container, parentPage)
 {
     this.Text     = "{0} Properties";
     this._dirnode = dirnode;
     InitializeComponent();
     _plugin    = plugin;
     _container = container;
     InitializePages();
 }
 public ADGroupPropertiesDlg(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin,ADUCDirectoryNode dirnode)
 : base(container, parentPage)
 {
     this.Text = "{0} Properties";
     this._dirnode = dirnode;
     InitializeComponent();
     _plugin = plugin;
     _container = container;
     InitializePages();
 }
        /// <summary>
        /// Method to load data to the tab pages while loading
        /// Gets all the tab pages that are of type MPage and gets call the SetData()
        /// Queries the ldap message to the selected node
        /// </summary>
        /// <param name="ce"></param>
        /// <param name="servername"></param>
        /// <param name="computer"></param>
        /// <param name="dirnode"></param>
        /// <param name="ldapSchemaCache"></param>
        public void SetData(CredentialEntry ce, string servername, string sOU, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache)
        {
            Applied = false;
            _plugin = dirnode.Plugin as ADUCPlugin;

            objInfo = new ObjectPropertyInfo
                          (ce,
                          servername,
                          sOU,
                          dirnode,
                          null);

            threadMain = new Thread(new ThreadStart(AddPagesToThread));
            threadMain.Start();
        }
Beispiel #10
0
        public GroupMembersPage(IPlugInContainer container, ADUCPlugin plugin)
        {
            this.pageID = "GroupMembersEditProperities";
            InitializeComponent();

            // Create an instance of a ListView column sorter and assign it
            // to the ListView control.
            lvwColumnSorter = new ListViewColumnSorter();
            this.MemoflistView.ListViewItemSorter = lvwColumnSorter;

            SetPageTitle("Members");
            _plugin         = plugin;
            _container      = container;
            OriginalObjects = new List <string>();
            ModifiedObjects = new List <string>();
        }
        public GroupMembersPage(IPlugInContainer container, ADUCPlugin plugin)
        {
            this.pageID = "GroupMembersEditProperities";
            InitializeComponent();

            // Create an instance of a ListView column sorter and assign it
            // to the ListView control.
            lvwColumnSorter = new ListViewColumnSorter();
            this.MemoflistView.ListViewItemSorter = lvwColumnSorter;

            SetPageTitle("Members");
            _plugin = plugin;
            _container = container;
            OriginalObjects = new List<string>();
            ModifiedObjects = new List<string>();
        }
Beispiel #12
0
        public ComputerMemOfPage(IPlugInContainer container, ADUCPlugin plugin)
        {
            this.pageID = "ComputerMemofEditProperities";
            InitializeComponent();

            // Create an instance of a ListView column sorter and assign it
            // to the ListView control.
            lvwColumnSorter = new ListViewColumnSorter();
            this.MemoflistView.ListViewItemSorter = lvwColumnSorter;

            SetPageTitle("Member of");
            _plugin       = plugin;
            _container    = container;
            MemofDnList   = new List <string>();
            AddedGroups   = new List <string>();
            RemovedGroups = new List <string>();
        }
    public UserMemOfPage(IPlugInContainer container, ADUCPlugin plugin)
    {
        this.pageID = "UserMemofEditProperities";
        InitializeComponent();

        // Create an instance of a ListView column sorter and assign it
        // to the ListView control.
        lvwColumnSorter = new ListViewColumnSorter();
        this.MemoflistView.ListViewItemSorter = lvwColumnSorter;

        SetPageTitle("Member of");
        _plugin = plugin;
        _container = container;
        MemofDnList = new List<string>();
        AddedGroups = new List<string>();
        RemovedGroups = new List<string>();
    }
        /// <summary>
        /// Method to load data to the tab pages while loading
        /// Gets all the tab pages that are of type MPage and gets calls the SetData()
        /// Queries the ldap message to the selected node
        /// </summary>
        /// <param name="ce"></param>
        /// <param name="servername"></param>
        /// <param name="computer"></param>
        /// <param name="dirnode"></param>
        /// <param name="ldapSchemaCache"></param>
        public void SetData(CredentialEntry ce, string servername, string group, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache)
        {
            Applied   = false;
            _plugin   = dirnode.Plugin as ADUCPlugin;
            this.Text = String.Format(this.Text, group);

            objInfo = new ObjectPropertyInfo(ce,
                                             servername,
                                             group,
                                             dirnode,
                                             null
                                             );

            threadMain = new Thread(new ThreadStart(AddPagesToThread));
            threadMain.Start();

            _plugin.Propertywindowhandles.Add(objInfo.dirnode.DistinguishedName, this);
        }
        /// <summary>
        /// Override constructor gets the Plugin node and all its childs
        /// Adds the all nodes to the treeview
        /// </summary>
        /// <param name="container"></param>
        /// <param name="parentPage"></param>
        /// <param name="plugin"></param>
        /// <param name="origTreeview"></param>
        public ADMoveObjectPage(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin, LWTreeView origTreeview)
            : this()
        {
            this.IPlugInContainer = container;
            _addplugin            = plugin;

            _origLWTreeView = origTreeview;

            _aducRootnode = _addplugin.GetPlugInNode();

            if (_aducRootnode.Nodes.Count > 0)
            {
                /*TreeNode[] newTreeArray = new TreeNode[_aducRootnode.Nodes.Count];
                 * // Iterate through the root nodes in the Nodes property.
                 * _aducRootnode.Nodes.CopyTo(newTreeArray, 0);
                 * foreach (TreeNode node in newTreeArray)
                 * {
                 *  LACTreeNode lacnode = node as LACTreeNode;
                 *  //   treeView1.Nodes.Add(lacnode.DeepCopy() as TreeNode);
                 * }*/
                ADUCDirectoryNode rootNode =
                    ADUCDirectoryNode.GetDirectoryRoot(_addplugin.GetpluginContext(),
                                                       _addplugin.GetRootDN(),
                                                       Resources.ADUC, typeof(ADUCPage), _addplugin);

                if (rootNode != null)
                {
                    treeView1.Nodes.Add(rootNode);
                    ADUCDirectoryNode[] childNodes = rootNode.ListContainerChildren(rootNode);
                    if (childNodes != null)
                    {
                        rootNode.Nodes.AddRange(childNodes);
                    }
                    treeView1.ExpandAll();
                }
            }
            else
            {
                Logger.Log("The LWTreeView control does not have any nodes.");
            }
        }
    /// <summary>
    /// Override constructor gets the Plugin node and all its childs
    /// Adds the all nodes to the treeview
    /// </summary>
    /// <param name="container"></param>
    /// <param name="parentPage"></param>
    /// <param name="plugin"></param>
    /// <param name="origTreeview"></param>
    public ADMoveObjectPage(IPlugInContainer container, StandardPage parentPage, ADUCPlugin plugin, LWTreeView origTreeview)
    : this()
    {
        this.IPlugInContainer = container;
        _addplugin = plugin;
        
        _origLWTreeView = origTreeview;
        
        _aducRootnode = _addplugin.GetPlugInNode();
        
        if (_aducRootnode.Nodes.Count > 0)
        {
                /*TreeNode[] newTreeArray = new TreeNode[_aducRootnode.Nodes.Count];
                // Iterate through the root nodes in the Nodes property.
                _aducRootnode.Nodes.CopyTo(newTreeArray, 0);
                foreach (TreeNode node in newTreeArray)
                {
                    LACTreeNode lacnode = node as LACTreeNode;
                    //   treeView1.Nodes.Add(lacnode.DeepCopy() as TreeNode);
                }*/
            ADUCDirectoryNode rootNode =
            ADUCDirectoryNode.GetDirectoryRoot(_addplugin.GetpluginContext(),          
            _addplugin.GetRootDN(),
            Resources.ADUC, typeof (ADUCPage), _addplugin);

            if (rootNode != null)
            {
                treeView1.Nodes.Add(rootNode);
                ADUCDirectoryNode[] childNodes = rootNode.ListContainerChildren(rootNode);
                if (childNodes != null)
                    rootNode.Nodes.AddRange(childNodes);
                treeView1.ExpandAll();
            }
        }
        else
        {
            Logger.Log("The LWTreeView control does not have any nodes.");
        }
    }
Beispiel #17
0
        /// <summary>
        /// Queries and fills the ldap message for the selected group
        /// Gets the attribute list from AD for group schema attribute.
        /// search for the attributes description, cn or name and displays them in a controls
        /// </summary>
        /// <param name="ce"></param>
        /// <param name="servername"></param>
        /// <param name="name"></param>
        /// <param name="dirnode"></param>
        public void SetData(CredentialEntry ce, string servername, string name, ADUCDirectoryNode dirnode)
        {
            try
            {
                this.dirnode = dirnode;
                this.plugin  = dirnode.Plugin as ADUCPlugin;
                DirectoryContext dirContext = dirnode.LdapContext;
                Logonname    = "";
                PreLogonname = "";

                //first obtain the current userAccountControl value
                DirectoryEntry de          = new DirectoryEntry(string.Format("LDAP://{0}/{1}", dirContext.DomainName, dirnode.DistinguishedName));
                int            userCtrlInt = Convert.ToInt32(de.Properties["userAccountControl"].Value.ToString());
                long           pwdLastSet  = Convert.ToInt64(de.Properties["pwdLastSet"].Value.ToString());
                sUserWorkStations = de.Properties["userWorkstations"].Value as string;

                if (de.Properties["userPrincipalName"].Value != null)
                {
                    Logonname     = de.Properties["userPrincipalName"].Value as string;
                    Logonname     = Logonname.IndexOf('@') >= 0 ? Logonname.Substring(0, Logonname.IndexOf('@')) : Logonname;
                    txtlogon.Text = Logonname;
                }

                txtpreLogonname.Text = de.Properties["sAMAccountName"].Value as string;
                PreLogonname         = txtpreLogonname.Text.Trim();

                txtDomian.Text = dirContext.DomainName.Substring(0, dirContext.DomainName.IndexOf('.')).ToUpper() + @"\";
                cbDomain.Items.Add(string.Concat("@", dirContext.DomainName.ToUpper()));
                cbDomain.SelectedIndex = 0;

                double accountExpires = Convert.ToInt64(de.Properties["accountExpires"].Value);

                if (accountExpires == 9223372036854775807)
                {
                    rbNever.Checked = true;
                }
                else
                {
                    rbEndOf.Checked = true;
                    ConvertFromUnixTimestamp(accountExpires);
                }
                try
                {
                    string userCtrlBinStr = UserGroupUtils.DecimalToBase(userCtrlInt, 2);

                    if (userCtrlBinStr.Length >= 10 && userCtrlBinStr[userCtrlBinStr.Length - 10] == '1')
                    {
                        bMustChangePwd = true;
                    }
                    if (userCtrlBinStr.Length >= 10 && userCtrlBinStr[userCtrlBinStr.Length - 2] == '1')
                    {
                        bAcountDisable = true;
                    }
                    if (userCtrlBinStr.Length >= 17 && userCtrlBinStr[userCtrlBinStr.Length - 17] == '1')
                    {
                        bNeverExpiresPwd = true;
                        bMustChangePwd   = false;
                    }
                    if (userCtrlBinStr.Length >= 10 && userCtrlBinStr[userCtrlBinStr.Length - 7] == '1' &&
                        pwdLastSet != 0)
                    {
                        bUserCannotChange = true;
                    }
                    if (userCtrlBinStr.Length >= 8 && userCtrlBinStr[userCtrlBinStr.Length - 8] == '1')
                    {
                        bStorePwd = true;
                    }
                    if (userCtrlBinStr.Length >= 19 && userCtrlBinStr[userCtrlBinStr.Length - 19] == '1')
                    {
                        bSmartCardRequired = true;
                    }
                    if (userCtrlBinStr.Length >= 21 && userCtrlBinStr[userCtrlBinStr.Length - 21] == '1')
                    {
                        bAccSensitive = true;
                    }
                    if (userCtrlBinStr.Length >= 22 && userCtrlBinStr[userCtrlBinStr.Length - 22] == '1')
                    {
                        bUseDESDescription = true;
                    }
                    if (userCtrlBinStr.Length >= 23 && userCtrlBinStr[userCtrlBinStr.Length - 23] == '1')
                    {
                        bNotKrbAuthentication = true;
                    }
                }
                catch
                {
                }

                FillUserOptions();

                dateTimePicker.Enabled = rbEndOf.Checked;

                this.ParentContainer.DataChanged      = false;
                this.ParentContainer.btnApply.Enabled = false;
            }
            catch (Exception e)
            {
                Logger.LogException("UserAccountPage.SetData", e);
            }
        }
        /// <summary>
        /// Queries and fills the ldap message for the selected group
        /// Gets the attribute list from AD for group schema attribute.
        /// search for the attributes description, cn or name and displays them in a controls
        /// </summary>
        /// <param name="ce"></param>
        /// <param name="servername"></param>
        /// <param name="name"></param>
        /// <param name="dirnode"></param>
        public void SetData(CredentialEntry ce, string servername, string name, ADUCDirectoryNode dirnode)
        {
            try
            {
                this.dirnode = dirnode;
                this.plugin = dirnode.Plugin as ADUCPlugin;
                DirectoryContext dirContext = dirnode.LdapContext;
                Logonname = "";
                PreLogonname = "";

                //first obtain the current userAccountControl value
                DirectoryEntry de = new DirectoryEntry(string.Format("LDAP://{0}/{1}", dirContext.DomainName, dirnode.DistinguishedName));
                int userCtrlInt = Convert.ToInt32(de.Properties["userAccountControl"].Value.ToString());
                long pwdLastSet = Convert.ToInt64(de.Properties["pwdLastSet"].Value.ToString());
                sUserWorkStations = de.Properties["userWorkstations"].Value as string;

                if (de.Properties["userPrincipalName"].Value != null)
                {
                    Logonname = de.Properties["userPrincipalName"].Value as string;
                    Logonname = Logonname.IndexOf('@') >= 0 ? Logonname.Substring(0, Logonname.IndexOf('@')) : Logonname;
                    txtlogon.Text = Logonname;
                }

                txtpreLogonname.Text = de.Properties["sAMAccountName"].Value as string;
                PreLogonname = txtpreLogonname.Text.Trim();

                txtDomian.Text = dirContext.DomainName.Substring(0, dirContext.DomainName.IndexOf('.')).ToUpper() + @"\";
                cbDomain.Items.Add(string.Concat("@", dirContext.DomainName.ToUpper()));
                cbDomain.SelectedIndex = 0;

                double accountExpires = Convert.ToInt64(de.Properties["accountExpires"].Value);

                if (accountExpires == 9223372036854775807)
                    rbNever.Checked = true;
                else
                {
                    rbEndOf.Checked = true;
                    ConvertFromUnixTimestamp(accountExpires);
                }
                try
                {
                    string userCtrlBinStr = UserGroupUtils.DecimalToBase(userCtrlInt, 2);

                    if (userCtrlBinStr.Length >= 10 && userCtrlBinStr[userCtrlBinStr.Length - 10] == '1')
                    {
                        bMustChangePwd = true;
                    }
                    if (userCtrlBinStr.Length >= 10 && userCtrlBinStr[userCtrlBinStr.Length - 2] == '1')
                    {
                        bAcountDisable = true;
                    }
                    if (userCtrlBinStr.Length >= 17 && userCtrlBinStr[userCtrlBinStr.Length - 17] == '1')
                    {
                        bNeverExpiresPwd = true;
                        bMustChangePwd = false;
                    }
                    if (userCtrlBinStr.Length >= 10 && userCtrlBinStr[userCtrlBinStr.Length - 7] == '1'
                        && pwdLastSet != 0)
                    {
                        bUserCannotChange = true;
                    }
                    if (userCtrlBinStr.Length >= 8 && userCtrlBinStr[userCtrlBinStr.Length - 8] == '1')
                    {
                        bStorePwd = true;
                    }
                    if (userCtrlBinStr.Length >= 19 && userCtrlBinStr[userCtrlBinStr.Length - 19] == '1')
                    {
                        bSmartCardRequired = true;
                    }
                    if (userCtrlBinStr.Length >= 21 && userCtrlBinStr[userCtrlBinStr.Length - 21] == '1')
                    {
                        bAccSensitive = true;
                    }
                    if (userCtrlBinStr.Length >= 22 && userCtrlBinStr[userCtrlBinStr.Length - 22] == '1')
                    {
                        bUseDESDescription = true;
                    }
                    if (userCtrlBinStr.Length >= 23 && userCtrlBinStr[userCtrlBinStr.Length - 23] == '1')
                    {
                        bNotKrbAuthentication = true;
                    }
                }
                catch
                {
                }

                FillUserOptions();

                dateTimePicker.Enabled = rbEndOf.Checked;

                this.ParentContainer.DataChanged = false;
                this.ParentContainer.btnApply.Enabled = false;
            }
            catch (Exception e)
            {
                Logger.LogException("UserAccountPage.SetData", e);
            }
        }
Beispiel #19
0
        private void MemoflistView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (MemoflistView.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = MemoflistView.SelectedItems[0];
                if (selectedItem.Tag != null)
                {
                    string distinguishedName = selectedItem.Tag.ToString();
                    if (distinguishedName.Equals(_dirnode.DistinguishedName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return;
                    }
                    ADUCPlugin plugin = _dirnode.Plugin as ADUCPlugin;
                    if (plugin.Propertywindowhandles.ContainsKey(distinguishedName))
                    {
                        Form f = plugin.Propertywindowhandles[distinguishedName] as Form;
                        f.BringToFront();
                        return;
                    }
                    string         sLDAPPath = string.Format("LDAP://{0}/{1}", _dirnode.LdapContext.DomainName, distinguishedName);
                    DirectoryEntry entry     = new DirectoryEntry(sLDAPPath, _dirnode.LdapContext.UserName, _dirnode.LdapContext.Password);
                    if (entry == null)
                    {
                        return;
                    }

                    object[] asProp = entry.Properties["objectClass"].Value as object[];

                    // poke these in a list for easier reference
                    List <string> liClasses = new List <string>();
                    foreach (string s in asProp)
                    {
                        liClasses.Add(s);
                    }

                    if (liClasses.Contains("computer"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "computer",
                                                                          Properties.Resources.computer, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                        ADComputerPropertiesDlg f = new ADComputerPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                    else if (liClasses.Contains("group"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "group",
                                                                          Properties.Resources.Group_48, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                        ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnode);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                    else if (liClasses.Contains("user"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "user",
                                                                          Properties.Resources.User, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);

                        List <object> dirnodes = new List <object>();
                        dirnodes.Add(dirnode);
                        ADUserPropertiesDlg f = new ADUserPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnodes);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                    else if (liClasses.Contains("foreignSecurityPrincipal"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "foreignSecurityPrincipal",
                                                                          Properties.Resources.Group_48, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                        ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnode);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                }
            }
        }
Beispiel #20
0
    /// <summary>
    /// Sets the Plugin information to base
    /// List the all child nodes, then refreshes the listview with the all child treenodes.
    /// </summary>
    /// <param name="ccontainer"></param>
    /// <param name="pi"></param>
    /// <param name="treeNode"></param>
    /// <param name="lmctreeview"></param>
    public override void SetPlugInInfo(IPlugInContainer ccontainer, IPlugIn pi, LACTreeNode treeNode, LWTreeView lmctreeview, CServerControl sc)
    {

        base.SetPlugInInfo(ccontainer, pi, treeNode, lmctreeview, sc);
        bEnableActionMenu = false;
        ADUCDirectoryNode node = treeNode as ADUCDirectoryNode;

        plugin = pi as ADUCPlugin;

        plugin.aducPagelvChildNodes = lvChildNodes;

        ctx = (IContext)plugin.HostInfo;

        if (node != null)
        {
            SetCaption(node.DistinguishedName);
            RefreshlvChildNodes(node);
        }
        else
        {
            RefreshlvChildNodes(treeNode);
            string sADUC = "Active Directory Users && Computers";
            SetCaption(sADUC);
        }
    }
        /// <summary>
        /// Method to load data to the tab pages while loading
        /// Gets all the tab pages that are of type MPage and get calls the SetData()
        /// Queries the ldap message to the selected node
        /// </summary>
        /// <param name="ce"></param>
        /// <param name="servername"></param>
        /// <param name="user"></param>
        /// <param name="dirnode"></param>
        /// <param name="ldapSchemaCache"></param>
        public void SetData(CredentialEntry ce, string servername, string user, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache)
        {
            Applied = false;
            _plugin = dirnode.Plugin as ADUCPlugin;
            this.Text = String.Format(this.Text, user);

            objInfo = new ObjectPropertyInfo
                                      (ce,
                                      servername,
                                      user,
                                      dirnode,
                                      null
                                      );

            threadMain = new Thread(new ThreadStart(AddPagesToThread));
            threadMain.Start();

            _plugin.Propertywindowhandles.Add(objInfo.dirnode.DistinguishedName, this);
        }
Beispiel #22
0
        /// <summary>
        /// List the all children for the selected distinguished name
        /// Adds the all children to the node
        /// </summary>
        public void ListChildren()
        {
            Logger.Log("ADUCDirectoryNode.ListChildren() called", Logger.ldapLogLevel);
            int ret = -1;

            if (haveRetrievedChildren && !this.IsModified)
            {
                return;
            }

            string[] attrList = new string[]
            {
                "dummy",
                "objectClass",
                "distinguishedName",
                "userAccountControl",
                null
            };

            ret = dirContext.ListChildEntriesSynchronous
                      (distinguishedName,
                      LdapAPI.LDAPSCOPE.ONE_LEVEL,
                      "(objectClass=*)",
                      attrList,
                      false,
                      out ldapEntries);

            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                //clears the domian level node, if the ldap connection timed out or disconnected
                ADUCPlugin plugin = this.Plugin as ADUCPlugin;
                haveRetrievedChildren = true;
                this.IsModified       = false;
                if (ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_SERVER_DOWN ||
                    ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_CONNECT_ERROR ||
                    ret == -1)
                {
                    if (ret == -1)
                    {
                        ret = (int)ErrorCodes.LDAPEnum.LDAP_TIMEOUT;
                        Logger.LogMsgBox(ErrorCodes.LDAPString(ret));
                    }
                    plugin._pluginNode.Nodes.Clear();
                    this.sc.ShowControl(plugin._pluginNode);
                }
                else
                {
                    Nodes.Clear();
                }

                return;
            }
            else if (IsModified)
            {
                Nodes.Clear();
            }

            DateTime timer = Logger.StartTimer();

            //The following is optimized for speed, taking into account that in Mono,
            //Nodes.Add() and Nodes.AddRange() both take a long time to complete.
            //Nodes.AddRange() does not offer much time savings over Nodes.Add()
            //Therefore, make two hashtables holding the new and old contents of the DN.
            //Determine which have been added, and which have been deleted, to minimize the number of calls
            //to Nodes.Add() and Nodes.Remove();
            Hashtable oldEntries = new Hashtable();
            Hashtable newEntries = new Hashtable();

            List <ADUCDirectoryNode> nodesToAdd = new List <ADUCDirectoryNode>();
            int nodesAdded = 0;

            foreach (TreeNode node in Nodes)
            {
                ADUCDirectoryNode dNode = (ADUCDirectoryNode)node;
                if (dNode != null && !String.IsNullOrEmpty(dNode.distinguishedName) &&
                    !oldEntries.ContainsKey(dNode.distinguishedName))
                {
                    oldEntries.Add(dNode.distinguishedName, dNode);
                }
            }

            foreach (LdapEntry ldapNextEntry in ldapEntries)
            {
                string currentDN = ldapNextEntry.GetDN();

                if (!String.IsNullOrEmpty(currentDN))
                {
                    LdapValue[] values      = ldapNextEntry.GetAttributeValues("objectClass", dirContext);
                    string      objectClass = "";
                    if (values != null && values.Length > 0)
                    {
                        objectClass = values[values.Length - 1].stringData;
                    }

                    bool IsDisabled = false;
                    bool IsDc       = false;
                    if (objectClass.Equals("user", StringComparison.InvariantCultureIgnoreCase) ||
                        objectClass.Equals("computer", StringComparison.InvariantCultureIgnoreCase))
                    {
                        values = ldapNextEntry.GetAttributeValues("userAccountControl", dirContext);
                        int userCtrlVal = 0;
                        if (values != null && values.Length > 0)
                        {
                            userCtrlVal = Convert.ToInt32(values[0].stringData);
                        }
                        if (userCtrlVal.Equals(8224) || userCtrlVal.Equals(8202) || userCtrlVal.Equals(532480))
                        {
                            IsDc = true;
                        }
                        string userCtrlBinStr = UserGroupUtils.DecimalToBase(userCtrlVal, 2);

                        //Determine whether this user is enabled or disabled
                        //examine the second to last position from the right (0=Active, 1=Inactive)
                        if (userCtrlBinStr.Length >= 2)
                        {
                            if (userCtrlBinStr[userCtrlBinStr.Length - 2] == '1')
                            {
                                IsDisabled = true;
                            }
                            else if (userCtrlBinStr[userCtrlBinStr.Length - 2] == '0')
                            {
                                IsDisabled = false;
                            }
                        }
                    }

                    ADUCDirectoryNode newNode = new ADUCDirectoryNode(currentDN, dirContext, objectClass,
                                                                      Resources.Group_16, NodeType, Plugin, IsDisabled);
                    newNode.sc = this.sc;
                    newNode._IsDomainController = IsDc;
                    newNode.Text = newNode.Text.Substring(3);

                    Logger.Log(String.Format("new Entry: {0}", currentDN), Logger.ldapLogLevel);

                    newEntries.Add(currentDN, newNode);

                    if (oldEntries.ContainsKey(currentDN))
                    {
                        ADUCDirectoryNode oldNode = (ADUCDirectoryNode)oldEntries[currentDN];

                        if ((oldNode != null && oldNode.ObjectClass != objectClass)
                            ||
                            (oldNode != null && oldNode.IsDisabled != IsDisabled))
                        {
                            oldEntries.Remove(currentDN);
                            oldEntries.Add(currentDN, newNode);
                            Nodes.Remove(oldNode);
                            nodesToAdd.Add(newNode);
                            nodesAdded++;
                        }
                    }
                    else
                    {
                        Logger.Log(String.Format("scheduling addition of new Entry: {0}", currentDN), Logger.ldapLogLevel);
                        nodesToAdd.Add(newNode);
                        nodesAdded++;
                    }
                }
            }

            foreach (Object o in oldEntries.Keys)
            {
                string oldNodeKey = (string)o;

                Logger.Log(String.Format("old Entry: {0}", oldNodeKey));

                if (!String.IsNullOrEmpty(oldNodeKey) && !newEntries.ContainsKey(oldNodeKey))
                {
                    ADUCDirectoryNode oldNode = (ADUCDirectoryNode)oldEntries[oldNodeKey];

                    if (oldNode != null)
                    {
                        Logger.Log(String.Format("removing old Entry: {0}", oldNodeKey), Logger.ldapLogLevel);

                        Nodes.Remove(oldNode);
                    }
                }
            }

            ADUCDirectoryNode[] nodesToAddRecast = new ADUCDirectoryNode[nodesAdded];
            try
            {
                nodesToAdd.Sort(delegate(ADUCDirectoryNode d1, ADUCDirectoryNode d2)
                {
                    return(d1.Text.CompareTo(d2.Text));
                }
                                );
                for (int i = 0; i < nodesAdded; i++)
                {
                    nodesToAddRecast[i] = nodesToAdd[i];
                }
            }
            catch (Exception)
            {
            }

            Nodes.AddRange(nodesToAddRecast);

            Logger.TimerMsg(ref timer, String.Format("DirectoryNode.ListChildren(): Entry Processing({0})", distinguishedName));
            this.IsModified       = false;
            haveRetrievedChildren = true;
        }
Beispiel #23
0
        /// <summary>
        /// List the all children for the selected distinguished name
        /// Adds the all children to the node
        /// </summary>
        public ADUCDirectoryNode[] ListChildren(ADUCDirectoryNode dnode)
        {
            Logger.Log("DirectoryNode.ListChildren() called", Logger.ldapLogLevel);
            int ret = -1;

            string[] attrList = new string[]
            {
                "dummy",
                "objectClass",
                "distinguishedName",
                "userAccountControl",
                null
            };

            ret = dirContext.ListChildEntriesSynchronous
                      (distinguishedName,
                      LdapAPI.LDAPSCOPE.ONE_LEVEL,
                      "(objectClass=*)",
                      attrList,
                      false,
                      out ldapEntries);

            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                //clears the domian level node, if the ldap connection timed out or disconnected
                ADUCPlugin plugin = this.Plugin as ADUCPlugin;
                haveRetrievedChildren = true;
                this.IsModified       = false;
                if (ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_SERVER_DOWN ||
                    ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_CONNECT_ERROR ||
                    ret == -1)
                {
                    if (ret == -1)
                    {
                        ret = (int)ErrorCodes.LDAPEnum.LDAP_TIMEOUT;
                        Logger.LogMsgBox(ErrorCodes.LDAPString(ret));
                    }
                    plugin._pluginNode.Nodes.Clear();
                    this.sc.ShowControl(plugin._pluginNode);
                }

                return(null);
            }

            DateTime timer = Logger.StartTimer();

            List <ADUCDirectoryNode> nodesToAdd = new List <ADUCDirectoryNode>();
            int nodesAdded = 0;

            foreach (LdapEntry ldapNextEntry in ldapEntries)
            {
                string currentDN = ldapNextEntry.GetDN();

                if (!String.IsNullOrEmpty(currentDN))
                {
                    bool IsDisabled = false;
                    bool IsDc       = false;

                    LdapValue[] values      = ldapNextEntry.GetAttributeValues("objectClass", dirContext);
                    string      objectClass = "";
                    if (values != null && values.Length > 0)
                    {
                        objectClass = values[values.Length - 1].stringData;
                    }

                    if (objectClass.Equals("user", StringComparison.InvariantCultureIgnoreCase) ||
                        objectClass.Equals("computer", StringComparison.InvariantCultureIgnoreCase))
                    {
                        values = ldapNextEntry.GetAttributeValues("userAccountControl", dirContext);
                        int userCtrlVal = 0;
                        if (values != null && values.Length > 0)
                        {
                            userCtrlVal = Convert.ToInt32(values[0].stringData);
                        }
                        if (userCtrlVal.Equals(8224) || userCtrlVal.Equals(8202) || userCtrlVal.Equals(532480))
                        {
                            IsDc = true;
                        }
                        string userCtrlBinStr = UserGroupUtils.DecimalToBase(userCtrlVal, 2);

                        //Determine whether this user is enabled or disabled
                        //examine the second to last position from the right (0=Active, 1=Inactive)
                        if (userCtrlBinStr.Length >= 2)
                        {
                            if (userCtrlBinStr[userCtrlBinStr.Length - 2] == '1')
                            {
                                IsDisabled = true;
                            }
                            else if (userCtrlBinStr[userCtrlBinStr.Length - 2] == '0')
                            {
                                IsDisabled = false;
                            }
                        }
                    }

                    ADUCDirectoryNode newNode = new ADUCDirectoryNode(currentDN, dirContext, objectClass,
                                                                      Resources.Group_16, NodeType, Plugin, IsDisabled);
                    newNode.sc = this.sc;
                    newNode._IsDomainController = IsDc;
                    newNode.Text = newNode.Text.Substring(3);

                    Logger.Log(String.Format("new Entry: {0}", currentDN), Logger.ldapLogLevel);
                    Logger.Log(String.Format("scheduling addition of new Entry: {0}", currentDN), Logger.ldapLogLevel);

                    nodesToAdd.Add(newNode);
                    nodesAdded++;
                }
            }

            ADUCDirectoryNode[] nodesToAddRecast = new ADUCDirectoryNode[nodesAdded];

            try
            {
                nodesToAdd.Sort(delegate(ADUCDirectoryNode d1, ADUCDirectoryNode d2)
                {
                    return(d1.Text.CompareTo(d2.Text));
                }
                                );
                for (int i = 0; i < nodesAdded; i++)
                {
                    nodesToAddRecast[i] = nodesToAdd[i];
                }
            }
            catch (Exception)
            {
            }
            Logger.TimerMsg(ref timer, String.Format("DirectoryNode.ListChildren(): Entry Processing({0})", distinguishedName));
            this.IsModified       = false;
            haveRetrievedChildren = true;

            return(nodesToAddRecast);
        }
Beispiel #24
0
        /// <summary>
        /// Getting added all children to the selected node that are of type ObjectClass="group"
        /// </summary>
        public void ListGroupOUChildren()
        {
            int ret = -1;

            if (haveRetrievedChildren && !this.IsModified)
            {
                return;
            }

            string[] attrs = { "objectClass", "distinguishedName", null };

            DateTime start = DateTime.Now;

            ret = dirContext.ListChildEntriesSynchronous
                      (distinguishedName,
                      LdapAPI.LDAPSCOPE.ONE_LEVEL,
                      "(objectClass=*)",
                      attrs,
                      false,
                      out ldapEntries);

            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                //haveRetrievedChildren = true;
                //return;

                //clears the domian level node, if the ldap connection timed out or disconnected
                ADUCPlugin plugin = this.Plugin as ADUCPlugin;
                haveRetrievedChildren = true;
                this.IsModified       = false;
                if (ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_SERVER_DOWN ||
                    ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_CONNECT_ERROR ||
                    ret == -1)
                {
                    if (ret == -1)
                    {
                        ret = (int)ErrorCodes.LDAPEnum.LDAP_TIMEOUT;
                        Logger.LogMsgBox(ErrorCodes.LDAPString(ret));
                    }
                    plugin._pluginNode.Nodes.Clear();
                    this.sc.ShowControl(plugin._pluginNode);
                }
                else
                {
                    Nodes.Clear();
                }

                return;
            }

            foreach (LdapEntry ldapNextEntry in ldapEntries)
            {
                string s           = ldapNextEntry.GetDN();
                string objectClass = "";

                LdapValue[] values = ldapNextEntry.GetAttributeValues("objectClass", dirContext);
                if (values != null && values.Length > 0)
                {
                    //use the most specific object Class, which will be listed last.
                    objectClass = values[values.Length - 1].stringData;

                    Logger.Log("Start--", Logger.ldapLogLevel);
                    for (int i = 0; i < values.Length; i++)
                    {
                        Logger.Log("objectclass is " + values[i], Logger.ldapLogLevel);
                    }
                    Logger.Log("End--", Logger.ldapLogLevel);
                }

                if (objectClass.Equals("group", StringComparison.InvariantCultureIgnoreCase) || objectClass.Equals("organizationalUnit", StringComparison.InvariantCultureIgnoreCase))
                {
                    ADUCDirectoryNode dtn = new ADUCDirectoryNode(s, dirContext, objectClass,
                                                                  Resources.Group_16, NodeType, Plugin, false);
                    dtn.sc = this.sc;
                    Nodes.Add(dtn);
                }
            }
            haveRetrievedChildren = true;
        }
Beispiel #25
0
        /// <summary>
        /// Getting added all children to the selected node that are of type ObjectClass="group"
        /// , ObjectClass="user", ObjectClass="computer", ObjectClass="organizationalUnit"
        /// </summary>
        public void ListGroupAndUserOUChildren()
        {
            int ret = -1;

            if (haveRetrievedChildren && !this.IsModified)
            {
                return;
            }

            string[] attrs = { "objectClass", "distinguishedName", null };

            DateTime start = DateTime.Now;

            ret = dirContext.ListChildEntriesSynchronous
                      (distinguishedName,
                      LdapAPI.LDAPSCOPE.ONE_LEVEL,
                      "(objectClass=*)",
                      attrs,
                      false,
                      out ldapEntries);

            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                //haveRetrievedChildren = true;
                //return;

                //clears the domian level node, if the ldap connection timed out or disconnected
                ADUCPlugin plugin = this.Plugin as ADUCPlugin;
                haveRetrievedChildren = true;
                this.IsModified       = false;
                if (ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_SERVER_DOWN ||
                    ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_CONNECT_ERROR ||
                    ret == -1)
                {
                    if (ret == -1)
                    {
                        ret = (int)ErrorCodes.LDAPEnum.LDAP_TIMEOUT;
                        Logger.LogMsgBox(ErrorCodes.LDAPString(ret));
                    }
                    plugin._pluginNode.Nodes.Clear();
                    this.sc.ShowControl(plugin._pluginNode);
                }
                else
                {
                    Nodes.Clear();
                }

                return;
            }

            foreach (LdapEntry ldapNextEntry in ldapEntries)
            {
                string s           = ldapNextEntry.GetDN();
                string objectClass = "";

                LdapValue[] values = ldapNextEntry.GetAttributeValues("objectClass", dirContext);
                if (values != null && values.Length > 0)
                {
                    //use the most specific object Class, which will be listed last.
                    objectClass = values[values.Length - 1].stringData;

                    Logger.Log("Start--", Logger.ldapLogLevel);
                    for (int i = 0; i < values.Length; i++)
                    {
                        Logger.Log("objectclass is " + values[i], Logger.ldapLogLevel);
                    }
                    Logger.Log("End--", Logger.ldapLogLevel);
                }

                if (objectClass.Equals("group", StringComparison.InvariantCultureIgnoreCase))
                {
                    ADUCDirectoryNode dtn = new ADUCDirectoryNode(s, dirContext, objectClass,
                                                                  Resources.Group_16, NodeType, Plugin, false);
                    dtn.sc = this.sc;
                    Nodes.Add(dtn);
                }

                bool IsDisabled = false;
                bool IsDc       = false;
                if (objectClass.Equals("user", StringComparison.InvariantCultureIgnoreCase) ||
                    objectClass.Equals("computer", StringComparison.InvariantCultureIgnoreCase))
                {
                    values = ldapNextEntry.GetAttributeValues("userAccountControl", dirContext);
                    int userCtrlVal = 0;
                    if (values != null && values.Length > 0)
                    {
                        userCtrlVal = Convert.ToInt32(values[0].stringData);
                    }
                    if (userCtrlVal.Equals(8224) || userCtrlVal.Equals(8202) || userCtrlVal.Equals(532480))
                    {
                        IsDc = true;
                    }
                    string userCtrlBinStr = UserGroupUtils.DecimalToBase(userCtrlVal, 2);

                    //Determine whether this user is enabled or disabled
                    //examine the second to last position from the right (0=Active, 1=Inactive)
                    if (userCtrlBinStr.Length >= 2)
                    {
                        if (userCtrlBinStr[userCtrlBinStr.Length - 2] == '1')
                        {
                            IsDisabled = true;
                        }
                        else if (userCtrlBinStr[userCtrlBinStr.Length - 2] == '0')
                        {
                            IsDisabled = false;
                        }
                    }

                    ADUCDirectoryNode dtn = new ADUCDirectoryNode(s, dirContext, objectClass,
                                                                  Resources.Group_16, NodeType, Plugin, IsDisabled);
                    dtn.sc = this.sc;
                    dtn._IsDomainController = IsDc;
                    Nodes.Add(dtn);
                }


                if (objectClass.Equals("organizationalUnit", StringComparison.InvariantCultureIgnoreCase))
                {
                    ADUCDirectoryNode dtn = new ADUCDirectoryNode(s, dirContext, objectClass,
                                                                  Resources.Group_16, NodeType, Plugin, false);
                    dtn.sc = this.sc;
                    Nodes.Add(dtn);
                }
            }
            haveRetrievedChildren = true;
        }
        /// <summary>
        /// Method to load data to the tab pages while loading
        /// Gets all the tab pages that are of type MPage and gets call the SetData()
        /// Queries the ldap message to the selected node
        /// </summary>
        /// <param name="ce"></param>
        /// <param name="servername"></param>
        /// <param name="computer"></param>
        /// <param name="dirnode"></param>
        /// <param name="ldapSchemaCache"></param>
        public void SetData(CredentialEntry ce, string servername, string sOU, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache)
        {
            Applied = false;
            _plugin = dirnode.Plugin as ADUCPlugin;

            objInfo = new ObjectPropertyInfo
                                     (ce,
                                     servername,
                                     sOU,
                                     dirnode,
                                     null);

            threadMain = new Thread(new ThreadStart(AddPagesToThread));
            threadMain.Start();
        }
Beispiel #27
0
        /// <summary>
        /// List the all children for the selected distinguished name
        /// Adds the all children to the node
        /// </summary>
        public ADUCDirectoryNode[] ListContainerChildren(ADUCDirectoryNode dnode)
        {
            Logger.Log("DirectoryNode.ListChildren() called", Logger.ldapLogLevel);
            int ret = -1;

            if (haveRetrievedChildren && !this.IsModified)
            {
                return(null);
            }

            string[] attrList = new string[]
            {
                "dummy",
                "objectClass",
                "distinguishedName",
                "userAccountControl",
                null
            };

            string ObjectClassFilters = "(|(objectClass=container)(objectClass=organizationalUnit)(objectClass=infrastructureUpdate)(objectClass=builtinDomain)(objectClass=LostAndFound))";

            ret = dirContext.ListChildEntriesSynchronous
                      (distinguishedName,
                      LdapAPI.LDAPSCOPE.ONE_LEVEL,
                      ObjectClassFilters,
                      attrList,
                      false,
                      out ldapEntries);

            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                //clears the domian level node, if the ldap connection timed out or disconnected
                ADUCPlugin plugin = this.Plugin as ADUCPlugin;
                haveRetrievedChildren = true;
                this.IsModified       = false;
                if (ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_SERVER_DOWN ||
                    ret == (int)Likewise.LMC.Utilities.ErrorCodes.LDAPEnum.LDAP_CONNECT_ERROR ||
                    ret == -1)
                {
                    if (ret == -1)
                    {
                        ret = (int)ErrorCodes.LDAPEnum.LDAP_TIMEOUT;
                        Logger.LogMsgBox(ErrorCodes.LDAPString(ret));
                    }
                    plugin._pluginNode.Nodes.Clear();
                    this.sc.ShowControl(plugin._pluginNode);
                }
                else
                {
                    Nodes.Clear();
                }

                return(null);
            }

            DateTime timer = Logger.StartTimer();

            //The following is optimized for speed, taking into account that in Mono,
            //Nodes.Add() and Nodes.AddRange() both take a long time to complete.
            //Nodes.AddRange() does not offer much time savings over Nodes.Add()
            //Therefore, make two hashtables holding the new and old contents of the DN.
            //Determine which have been added, and which have been deleted, to minimize the number of calls
            //to Nodes.Add() and Nodes.Remove();
            Hashtable oldEntries = new Hashtable();
            Hashtable newEntries = new Hashtable();

            List <ADUCDirectoryNode> nodesToAdd = new List <ADUCDirectoryNode>();
            int nodesAdded = 0;

            foreach (TreeNode node in Nodes)
            {
                ADUCDirectoryNode dNode = (ADUCDirectoryNode)node;
                if (dNode != null && !String.IsNullOrEmpty(dNode.distinguishedName) &&
                    !oldEntries.ContainsKey(dNode.distinguishedName))
                {
                    oldEntries.Add(dNode.distinguishedName, dNode);
                }
            }

            foreach (LdapEntry ldapNextEntry in ldapEntries)
            {
                string currentDN = ldapNextEntry.GetDN();

                if (!String.IsNullOrEmpty(currentDN))
                {
                    LdapValue[] values      = ldapNextEntry.GetAttributeValues("objectClass", dirContext);
                    string      objectClass = "";
                    if (values != null && values.Length > 0)
                    {
                        objectClass = values[values.Length - 1].stringData;
                    }

                    ADUCDirectoryNode newNode = new ADUCDirectoryNode(currentDN, dirContext, objectClass,
                                                                      Resources.Group_16, NodeType, Plugin, IsDisabled);
                    newNode.sc   = this.sc;
                    newNode.Text = newNode.Text.Substring(3);

                    Logger.Log(String.Format("new Entry: {0}", currentDN), Logger.ldapLogLevel);

                    newEntries.Add(currentDN, newNode);

                    if (oldEntries.ContainsKey(currentDN))
                    {
                        ADUCDirectoryNode oldNode = (ADUCDirectoryNode)oldEntries[currentDN];

                        if ((oldNode != null && oldNode.ObjectClass != objectClass)
                            ||
                            (oldNode != null && oldNode.IsDisabled != IsDisabled))
                        {
                            oldEntries.Remove(currentDN);
                            oldEntries.Add(currentDN, newNode);
                            Nodes.Remove(oldNode);
                            nodesToAdd.Add(newNode);
                            nodesAdded++;
                        }
                    }
                    else
                    {
                        Logger.Log(String.Format("scheduling addition of new Entry: {0}", currentDN), Logger.ldapLogLevel);
                        nodesToAdd.Add(newNode);
                        nodesAdded++;
                    }
                }
            }

            foreach (Object o in oldEntries.Keys)
            {
                string oldNodeKey = (string)o;

                Logger.Log(String.Format("old Entry: {0}", oldNodeKey));

                if (!String.IsNullOrEmpty(oldNodeKey) && !newEntries.ContainsKey(oldNodeKey))
                {
                    ADUCDirectoryNode oldNode = (ADUCDirectoryNode)oldEntries[oldNodeKey];

                    if (oldNode != null)
                    {
                        Logger.Log(String.Format("removing old Entry: {0}", oldNodeKey), Logger.ldapLogLevel);

                        Nodes.Remove(oldNode);
                    }
                }
            }

            ADUCDirectoryNode[] nodesToAddRecast = new ADUCDirectoryNode[nodesAdded];

            try
            {
                nodesToAdd.Sort(delegate(ADUCDirectoryNode d1, ADUCDirectoryNode d2)
                {
                    return(d1.Text.CompareTo(d2.Text));
                }
                                );
                for (int i = 0; i < nodesAdded; i++)
                {
                    nodesToAddRecast[i] = nodesToAdd[i];
                }
            }
            catch (Exception)
            {
            }
            Logger.TimerMsg(ref timer, String.Format("DirectoryNode.ListChildren(): Entry Processing({0})", distinguishedName));
            this.IsModified       = false;
            haveRetrievedChildren = true;

            return(nodesToAddRecast);
        }