private void btnPermissionsAdd_Click(object sender, EventArgs e)
        {
            object ADObjects = new object();

            ShowDsPickerDialog(ADObjects);

            System.DirectoryServices.Misc.ADObject[] ADobjectsArray = ADObjects as System.DirectoryServices.Misc.ADObject[];

            if (ADobjectsArray != null && ADobjectsArray.Length != 0)
            {
                foreach (System.DirectoryServices.Misc.ADObject ado in ADobjectsArray)
                {
                    string sAMAccountName = ado.de.Properties["sAMAccountName"].Value as string;
                    string UPN            = ado.de.Properties["userPrincipalName"].Value as string;
                    byte[] sObjectSid     = ado.de.Properties["objectSid"].Value as byte[];

                    string sSID = _securityDescriptor.ConvetByteSidToStringSid(sObjectSid);

                    PermissionEntry permissionEntryDlg = new PermissionEntry(_objectPath, lvPermissions.SelectedItems[0].Text);
                    permissionEntryDlg.InitializeData(null, _securityDescriptor);
                    if (permissionEntryDlg.ShowDialog(this) == DialogResult.OK && permissionEntryDlg.IsCommit)
                    {
                        Do_PermissionsEdit(permissionEntryDlg._daclInfo, sSID, UPN);
                        _addedObjects.Add(sAMAccountName, permissionEntryDlg._daclInfo);

                        DataChanged = true;
                    }
                }
            }
        }
        private void btnPermissionsEdit_Click(object sender, EventArgs e)
        {
            if (lvPermissions.SelectedItems.Count == 0)
            {
                return;
            }

            PermissionEntry permissionEntryDlg = new PermissionEntry(_objectPath, lvPermissions.SelectedItems[0].Text);

            permissionEntryDlg.InitializeData(lvPermissions.SelectedItems[0].Tag as List <LwAccessControlEntry>, _securityDescriptor);
            if (permissionEntryDlg.ShowDialog(this) == DialogResult.OK && permissionEntryDlg.IsCommit)
            {
                if (permissionEntryDlg._daclInfo != null)
                {
                    ListViewItem lvItem = lvPermissions.SelectedItems[0];
                    string       name   = lvItem.SubItems[1].Text.Substring(0, lvItem.SubItems[1].Text.IndexOf('('));

                    Do_PermissionsEdit(permissionEntryDlg._daclInfo, null, null);

                    if (_addedObjects.ContainsKey(name))
                    {
                        _addedObjects.Remove(name);
                    }

                    else if (_editedObjects.ContainsKey(name))
                    {
                        _editedObjects[name] = permissionEntryDlg._daclInfo;
                    }
                    else
                    {
                        _editedObjects.Add(name, permissionEntryDlg._daclInfo);
                    }

                    DataChanged = true;
                }
            }
        }
        private void btnPermissionsEdit_Click(object sender, EventArgs e)
        {
            if (lvPermissions.SelectedItems.Count == 0)
                return;

            PermissionEntry permissionEntryDlg = new PermissionEntry(_objectPath, lvPermissions.SelectedItems[0].Text);
            permissionEntryDlg.InitializeData(lvPermissions.SelectedItems[0].Tag as List<LwAccessControlEntry>, _securityDescriptor);
            if (permissionEntryDlg.ShowDialog(this) == DialogResult.OK && permissionEntryDlg.IsCommit)
            {
                if (permissionEntryDlg._daclInfo != null)
                {
                    ListViewItem lvItem = lvPermissions.SelectedItems[0];
                    string name = lvItem.SubItems[1].Text.Substring(0, lvItem.SubItems[1].Text.IndexOf('('));

                    Do_PermissionsEdit(permissionEntryDlg._daclInfo, null, null);

                    if (_addedObjects.ContainsKey(name))
                        _addedObjects.Remove(name);

                    else if (_editedObjects.ContainsKey(name))
                        _editedObjects[name] = permissionEntryDlg._daclInfo;
                    else
                        _editedObjects.Add(name, permissionEntryDlg._daclInfo);

                    DataChanged = true;
                }
            }
        }
        private void btnPermissionsAdd_Click(object sender, EventArgs e)
        {
            object ADObjects = new object();
            ShowDsPickerDialog(ADObjects);

            System.DirectoryServices.Misc.ADObject[] ADobjectsArray = ADObjects as System.DirectoryServices.Misc.ADObject[];

            if (ADobjectsArray != null && ADobjectsArray.Length != 0)
            {
                foreach (System.DirectoryServices.Misc.ADObject ado in ADobjectsArray)
                {
                    string sAMAccountName = ado.de.Properties["sAMAccountName"].Value as string;
                    string UPN = ado.de.Properties["userPrincipalName"].Value as string;
                    byte[] sObjectSid = ado.de.Properties["objectSid"].Value as byte[];

                    string sSID = _securityDescriptor.ConvetByteSidToStringSid(sObjectSid);

                    PermissionEntry permissionEntryDlg = new PermissionEntry(_objectPath, lvPermissions.SelectedItems[0].Text);
                    permissionEntryDlg.InitializeData(null, _securityDescriptor);
                    if (permissionEntryDlg.ShowDialog(this) == DialogResult.OK && permissionEntryDlg.IsCommit)
                    {
                        Do_PermissionsEdit(permissionEntryDlg._daclInfo, sSID, UPN);
                        _addedObjects.Add(sAMAccountName, permissionEntryDlg._daclInfo);

                        DataChanged = true;
                    }
                }
            }
        }