Пример #1
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("&Properties"))
            {
                ListViewItem Item = GetSelectedItem();

                if (Item == null)
                {
                    return;
                }

                string   sShare    = (string)Item.SubItems[0].Text;
                string[] Shareinfo = null;
                Hostinfo hn        = ctx as Hostinfo;

                if (plugin.fileHandle != null)
                {
                    Shareinfo = SharesAPI.GetShareInfo(plugin.fileHandle.Handle, sShare, hn.hostName);
                }
                else
                {
                    Shareinfo = SharesAPI.GetShareInfo(IntPtr.Zero, sShare, hn.hostName);
                }

                if (Shareinfo != null && Shareinfo.Length != 0)
                {
                    if (Shareinfo[0].Equals("share"))
                    {
                        SharePropertiesDlg shareDlg = new SharePropertiesDlg(container, this, plugin, hn);
                        shareDlg.SetData(hn.creds, sShare, Shareinfo);
                        shareDlg.ShowDialog(this);
                    }
                    else
                    {
                        string sMsg = "This has been shared for administrative purposes.\n The Share permissions and file security cannot be set";
                        container.ShowMessage(sMsg);
                    }
                }
            }

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
            }
        }
Пример #2
0
 private void ShowMessage(string sMsg)
 {
     MessageBox.Show(
         sMsg,
         CommonResources.GetString("Caption_Console"),
         MessageBoxButtons.OK,
         MessageBoxIcon.None);
     return;
 }
Пример #3
0
        private void ShowUserMessage()
        {
            string sMsg = string.Format("LAC cannot complete the password change for user {0} because : \n" +
                                        "The password does not meet the password policy reruirements.\nCheck the minimum password length," +
                                        "password complexity and \npassword history requirements", sUser);

            MessageBox.Show(this, sMsg, CommonResources.GetString("Caption_Console"),
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }
Пример #4
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
            }

            if (m != null && m.Text.Trim().Equals("Disconnect &All Sessions"))
            {
                DialogResult dlg = MessageBox.Show(this, "Are you sure you wish to close all sessions?",
                                                   CommonResources.GetString("Caption_Console"),
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.None,
                                                   MessageBoxDefaultButton.Button1);

                if (dlg == DialogResult.OK)
                {
                    foreach (ListViewItem Item in lvSessionPage.Items)
                    {
                        string sUserMachine = (string)Item.SubItems[1].Text;
                        string sUser        = (string)Item.SubItems[0].Text;

                        try
                        {
                            Hostinfo hn = ctx as Hostinfo;
                            Session.DeleteSession(hn.creds, hn.hostName, sUserMachine, sUser);
                        }
                        catch (Exception ex)
                        {
                            string sMsg = string.Format(Resources.Error_DeleteSessionError, ex.Message);
                            container.ShowError(sMsg);
                            break;
                        }
                    }
                    //Just do refresh once the files got closed on the treenode.
                    treeNode.sc.ShowControl(treeNode);
                }
            }
        }
Пример #5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtMinutes.Text.Trim()))
            {
                MessageBox.Show("Please enter a positive integer", CommonResources.GetString("Caption_Console"),
                                MessageBoxButtons.OK);
                return;
            }

            sRestartMunites = int.Parse(txtMinutes.Text.Trim());
            sRebootMsg      = richTextBoxMsg.Text.Trim();

            Close();
        }
Пример #6
0
        static void ValidateDeviceAuthenticationKey(string key, string paramName)
        {
            if (key != null)
            {
                int keyLength;
                if (!Utils.IsValidBase64(key, out keyLength))
                {
                    throw new ArgumentException(CommonResources.GetString(Resources.StringIsNotBase64, key), paramName);
                }

                if (keyLength < SecurityConstants.MinKeyLengthInBytes || keyLength > SecurityConstants.MaxKeyLengthInBytes)
                {
                    throw new ArgumentException(CommonResources.GetString(Resources.DeviceKeyLengthInvalid, SecurityConstants.MinKeyLengthInBytes, SecurityConstants.MaxKeyLengthInBytes));
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Handles the prev button
        /// </summary>
        private void btnPrev_Click(object sender, EventArgs e)
        {
            if (_eventsListView == null ||
                _eventsListView.Items.Count == 0 ||
                _eventsListView.SelectedItems.Count != 1 ||
                !btnPrev.Enabled)
            {
                return;
            }

            int iEntry = _eventsListView.SelectedItems[0].Index;

            if (iEntry == 0)
            {
                DialogResult dlg = MessageBox.Show(this, "You have reached the beginning of the Event log. Do you want to continue from the end?",
                                                   CommonResources.GetString("Caption_Console"), MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dlg == DialogResult.Yes)
                {
                    iEntry = _eventsListView.Items.Count;
                    btnPrev.Focus();
                }
                else
                {
                    btnPrev.Focus();
                    return;
                }
            }

            if (iEntry != 0)
            {
                // bump the count
                iEntry--;
            }

            // change the selection
            _eventsListView.SelectedItems[0].Selected = false;
            _eventsListView.Items[iEntry].Selected    = true;

            // scroll into view if necessary
            ScrollIntoView(iEntry);

            // update the button state
            SetButtonState();

            LoadData();
        }
Пример #8
0
        private void On_MenuClick(object sender, EventArgs args)
        {
            MenuItem mi = sender as MenuItem;

            switch (mi.Text.Trim())
            {
            case "New &User...":
            case "New &Group...":
                CreateDlg();
                break;

            case "&Add to Group...":
                ShowLUGPropertiesDlg();
                break;

            case "&Set Password...":
                SetPasswordDlg();
                break;

            case "&Rename...":
                ShowRenameDlg();
                break;

            case "&Properties...":
                ShowLUGPropertiesDlg();
                break;

            case "&Delete":
                DeleteDlg();
                break;

            case "&Refresh":
                treeNode.IsModified = true;
                treeNode.sc.ShowControl(treeNode);
                break;

            case "&Help":
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                break;
            }
        }
Пример #9
0
        private void btnClearEvtlog_Click(object sender, EventArgs e)
        {
            if (_plugin == null)
            {
                return;
            }

            UInt32 ret;

            string sMsg = string.Format("Are you sure do you want to clear the EventLog database?\n" +
                                        "\ni. Select on 'Yes' will clear the entire EventLog database." +
                                        "\nii. Select on 'No' clears all the records of the Log {0}", _parentPage.TreeNode.Text);

            DialogResult dlg = MessageBox.Show(this,
                                               sMsg,
                                               CommonResources.GetString("Caption_Console"),
                                               MessageBoxButtons.YesNoCancel,
                                               MessageBoxIcon.Question,
                                               MessageBoxDefaultButton.Button3);

            if (dlg == DialogResult.Yes)
            {
                ret = EventAPI.ClearEventLog(this._plugin.eventLogHandle.Handle);
                if (ret != 0)
                {
                    Logger.Log(string.Format("Unable to clear the events log database"));
                    return;
                }
                ClearListView();
            }
            else if (dlg == DialogResult.No)
            {
                ret = EventAPI.DeleteFromEventLog(this._plugin.eventLogHandle.Handle, string.Format("(EventTableCategoryId = '{0}')", _parentPage.TreeNode.Text));
                if (ret != 0)
                {
                    Logger.Log(string.Format("Unable to delete the events for the current log {0}", _parentPage.TreeNode.Text));
                    return;
                }
                ClearListView();
            }
            else
            {
                return;
            }
        }
Пример #10
0
        public override bool OnWizardFinish()
        {
            string           filterquery = string.Format("(&(objectClass=user)(name={0}))", this._userAddDlg.userInfo.fullName);
            List <LdapEntry> ldapEntries = null;

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

            int ret = _dirnode.LdapContext.ListChildEntriesSynchronous(
                _dirnode.DistinguishedName,
                Likewise.LMC.LDAP.Interop.LdapAPI.LDAPSCOPE.ONE_LEVEL,
                filterquery,
                attrList,
                false,
                out ldapEntries);

            if (ldapEntries != null && ldapEntries.Count != 0)
            {
                string sMsg = string.Format("LAC cannot create the new user object becuase the name {0} is already in use.\n" +
                                            "Select another name, and then try again", this._userAddDlg.userInfo.fullName);
                MessageBox.Show(this, sMsg, CommonResources.GetString("Caption_Console"),
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            if (_userAddDlg.userInfo.passWord.Equals(string.Empty) || _userAddDlg.userInfo.retypedpassWord.Equals(string.Empty) || _userAddDlg.userInfo.passWord.Length < _userAddDlg.userInfo.MinPasswordLength)
            {
                string sMsg = string.Format(
                    "LAC cannot create the object {0} because:\n" +
                    "Unable to update the password.The value provided for " +
                    "the new password does not meet the length, complexity, or\n" +
                    "history requirement of the domain.",
                    _userAddDlg.userInfo.fullName);
                MessageBox.Show(
                    sMsg,
                    CommonResources.GetString("Caption_Console"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return(false);
            }
            _userAddDlg.userInfo.commit = true;
            return(base.OnWizardFinish());
        }
        /// <summary>
        /// Adds the new entry in the listbox if it is not exists
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (bIsInt)
            {
                string value = txtAttrValue.Text.Trim();
                if ((value.Contains("-") && !value.StartsWith("-")) || !regNum.IsMatch(value))
                {
                    MessageBox.Show(this,
                                    "The value entered can contain only digits between 0 and 9.\nIf a negative value is desired a minus sign can be placed \nas the first character.",
                                    CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            ListViewItem lviArr = null;

            if (!txtAttrValue.Text.ToString().Trim().Equals(string.Empty))
            {
                for (int i = 0; i < listViewAttrValues.Items.Count; i++)
                {
                    if (listViewAttrValues.Items[i].Text.Trim().Equals(txtAttrValue.Text.ToString().Trim()))
                    {
                        DialogResult dlg = MessageBox.Show(
                            this,
                            "This value already exists in the list. Do you want to add it anyway?",
                            CommonResources.GetString("Caption_Console"),
                            MessageBoxButtons.OKCancel,
                            MessageBoxIcon.Asterisk);
                        if (dlg == DialogResult.OK)
                        {
                            break;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                string[] values = { txtAttrValue.Text.ToString().Trim() };
                lviArr = new ListViewItem(values);
                this.listViewAttrValues.Items.Add(lviArr);
            }
            txtAttrValue.Text = "";
        }
Пример #12
0
        /// <summary>
        /// Validate the data
        /// </summary>
        /// <returns></returns>
        private bool ValidateData()
        {
            string value = this.txtAttrValue.Text.Trim();

            if (value.Trim().Equals("<not set>"))
            {
                return(true);
            }

            if (this.Text.Trim().Equals("Large Integer Attribute Editor"))
            {
                if (value.Length > 19 || value.Length == 0)
                {
                    string sMsg =
                        "The value entered can contain only digits between 0 and 9.\n " +
                        "If a negative value is desired a minus sign can be placed\n " +
                        "as the first character and value should not exceed more than 19 characters";
                    MessageBox.Show(
                        this,
                        sMsg,
                        CommonResources.GetString("Caption_Console"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    return(false);
                }
            }
            else if (value.Length > 10 || value.Length == 0)
            {
                MessageBox.Show(this,
                                "The value entered can contain only digits between 0 and 9.\nIf a negative value is desired a minus sign can be placed \nas the first character and value should not exceed more than 10 characters",
                                CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if ((value.Contains("-") && !value.StartsWith("-")) || !regNum.IsMatch(value))
            {
                MessageBox.Show(this,
                                "The value entered can contain only digits between 0 and 9.\nIf a negative value is desired a minus sign can be placed \nas the first character.",
                                CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            return(true);
        }
Пример #13
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     Logger.Log(
         "newparent DN is " + moveInfo.newParentDn,
         Logger.ldapLogLevel);
     if (moveInfo.newParentDn.Equals("", StringComparison.InvariantCultureIgnoreCase))
     {
         MessageBox.Show(
             this,
             "Please select a location to move this object, or click \"Cancel\" to cancel the move operation.",
             CommonResources.GetString("Caption_Console"),
             MessageBoxButtons.OK);
     }
     else
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
Пример #14
0
 /// <summary>
 /// Gives the specified attribute value
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnOk_Click_1(object sender, EventArgs e)
 {
     if (txtAttrValue.Text.Trim() == "")
     {
         MessageBox.Show(
             this,
             "Value can not be empty",
             CommonResources.GetString("Caption_Console"),
             MessageBoxButtons.OK,
             MessageBoxIcon.Asterisk);
         return;
     }
     else
     {
         stringAttrValue   = txtAttrValue.Text;
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
Пример #15
0
        public override bool OnWizardFinish()
        {
            bool IsgroupTypeValid = false, IsObjectGroup = false;

            foreach (string key in _objectAddDlg.objectInfo.htMandatoryAttrList.Keys)
            {
                if (key.Trim().Equals("groupType"))
                {
                    string svalue = _objectAddDlg.objectInfo.htMandatoryAttrList[key] as string;
                    switch (svalue)
                    {
                    case "4":
                    case "2":
                    case "6":
                    case "2147483644":
                    case "2147483640":
                    case "2147483646":
                        IsgroupTypeValid = true;
                        break;

                    default:
                        MessageBox.Show(this, "The specified group type is invalid", CommonResources.GetString("Caption_Console"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        IsgroupTypeValid = false;
                        break;
                    }
                    IsObjectGroup = true;
                    break;
                }
            }
            if (!IsgroupTypeValid && IsObjectGroup)
            {
                return(false);
            }
            _objectAddDlg.objectInfo.commit = true;
            return(base.OnWizardFinish());
        }
Пример #16
0
        public override string OnWizardNext()
        {
            string Message;
            string AttrSyntax = this.cnSyntaxlabel.Text.ToString();
            string Attrvalue  = this.cntextBox.Text.ToString();

            if (AttrSyntax != "" && Attrvalue != "")
            {
                bool bSuccess = ObjectAddAttributesTab.ValidateData(Attrvalue, AttrSyntax, out Message);
                if (!bSuccess)
                {
                    MessageBox.Show(
                        this,
                        Message,
                        CommonResources.GetString("Caption_Console"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation);
                    this.cntextBox.Clear();
                    this.cntextBox.Focus();
                    return(WizardDialog.NoPageChange);
                }
            }
            if (_objectAddDlg.objectInfo.htMandatoryAttrList.ContainsKey(this.attrNameLabel.Text.Trim()))
            {
                _objectAddDlg.objectInfo.htMandatoryAttrList.Remove(this.attrNameLabel.Text.Trim());
            }
            _objectAddDlg.objectInfo.htMandatoryAttrList.Add(this.attrNameLabel.Text.Trim(), this.cntextBox.Text);

            if (_objectAddDlg.objectInfo.addedPages.Count != 0 &&
                _objectAddDlg.objectInfo.addedPages.Count > ObjectInfo.PageIndex)
            {
                return(_objectAddDlg.objectInfo.addedPages[ObjectInfo.PageIndex++]);
            }

            return(base.OnWizardNext());
        }
Пример #17
0
        public override object DecodeObject(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(null);
            }

            int size  = 0;
            int count = 0;

            AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.Array8, FormatCode.Array32, out size, out count);

            formatCode = AmqpEncoding.ReadFormatCode(buffer);
            Array array = null;

            switch (formatCode)
            {
            case FormatCode.Boolean:
                array = ArrayEncoding.Decode <bool>(buffer, size, count, formatCode);
                break;

            case FormatCode.UByte:
                array = ArrayEncoding.Decode <byte>(buffer, size, count, formatCode);
                break;

            case FormatCode.UShort:
                array = ArrayEncoding.Decode <ushort>(buffer, size, count, formatCode);
                break;

            case FormatCode.UInt:
            case FormatCode.SmallUInt:
                array = ArrayEncoding.Decode <uint>(buffer, size, count, formatCode);
                break;

            case FormatCode.ULong:
            case FormatCode.SmallULong:
                array = ArrayEncoding.Decode <ulong>(buffer, size, count, formatCode);
                break;

            case FormatCode.Byte:
                array = ArrayEncoding.Decode <sbyte>(buffer, size, count, formatCode);
                break;

            case FormatCode.Short:
                array = ArrayEncoding.Decode <short>(buffer, size, count, formatCode);
                break;

            case FormatCode.Int:
            case FormatCode.SmallInt:
                array = ArrayEncoding.Decode <int>(buffer, size, count, formatCode);
                break;

            case FormatCode.Long:
            case FormatCode.SmallLong:
                array = ArrayEncoding.Decode <long>(buffer, size, count, formatCode);
                break;

            case FormatCode.Float:
                array = ArrayEncoding.Decode <float>(buffer, size, count, formatCode);
                break;

            case FormatCode.Double:
                array = ArrayEncoding.Decode <double>(buffer, size, count, formatCode);
                break;

            case FormatCode.Char:
                array = ArrayEncoding.Decode <char>(buffer, size, count, formatCode);
                break;

            case FormatCode.TimeStamp:
                array = ArrayEncoding.Decode <DateTime>(buffer, size, count, formatCode);
                break;

            case FormatCode.Uuid:
                array = ArrayEncoding.Decode <Guid>(buffer, size, count, formatCode);
                break;

            case FormatCode.Binary32:
            case FormatCode.Binary8:
                array = ArrayEncoding.Decode <ArraySegment <byte> >(buffer, size, count, formatCode);
                break;

            case FormatCode.String32Utf8:
            case FormatCode.String8Utf8:
                array = ArrayEncoding.Decode <string>(buffer, size, count, formatCode);
                break;

            case FormatCode.Symbol32:
            case FormatCode.Symbol8:
                array = ArrayEncoding.Decode <AmqpSymbol>(buffer, size, count, formatCode);
                break;

            case FormatCode.List32:
            case FormatCode.List8:
                array = ArrayEncoding.Decode <IList>(buffer, size, count, formatCode);
                break;

            case FormatCode.Map32:
            case FormatCode.Map8:
                array = ArrayEncoding.Decode <AmqpMap>(buffer, size, count, formatCode);
                break;

            case FormatCode.Array32:
            case FormatCode.Array8:
                array = ArrayEncoding.Decode <Array>(buffer, size, count, formatCode);
                break;

            default:
                throw new NotSupportedException(CommonResources.GetString(CommonResources.NotSupportFrameCode, formatCode));
            }

            return(array);
        }
Пример #18
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (RenametextBox.Text.Length > 64)
     {
         if (obj_type.Equals("organizationalUnit", StringComparison.InvariantCultureIgnoreCase))
         {
             MessageBox.Show("LAC cannot complete the rename operation on \n" +
                             objname + " " + "A value for the attribute was not in the acceptable range of values \n \n" +
                             "Name-related properties on this object might now be out of sync.Contact your system administrator.", CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Error);
             rename = null;
             return;
         }
         else if (obj_type.Equals("user", StringComparison.InvariantCultureIgnoreCase) || obj_type.Equals("group", StringComparison.InvariantCultureIgnoreCase))
         {
             MessageBox.Show("The name you entered is too long.Names cannot contain more than 64 characters.This name willbe shortened to 64 \n" +
                             "characters", CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     if (RenametextBox.Text.Length > 64 && obj_type.Equals("group", StringComparison.InvariantCultureIgnoreCase))
     {
         rename = RenametextBox.Text.Trim().Substring(0, 64);
     }
     else if (RenametextBox.Text.Length > 64 && obj_type.Equals("user", StringComparison.InvariantCultureIgnoreCase))
     {
         rename = RenametextBox.Text.Trim().Substring(0, 64);
     }
     else
     {
         rename = RenametextBox.Text.Trim();
     }
     this.Close();
 }
Пример #19
0
        /// <summary>
        /// Removes the selected user/group from the list
        /// On Apply will removes the selected listview item from "members" attribute for the selected "group"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            if (MemoflistView.SelectedItems.Count > 0)
            {
                DialogResult dlg =
                    MessageBox.Show(this, "Do you want to remove the selected member(s) from the group?",
                                    CommonResources.GetString("Caption_Console"), MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                if (dlg == DialogResult.Yes)
                {
                    foreach (ListViewItem item in MemoflistView.SelectedItems)
                    {
                        string         sDn       = item.Tag as string;
                        string         sLdapPath = string.Format("LDAP://{0}/{1}", _dirnode.LdapContext.DomainName, sDn);
                        DirectoryEntry entry     = new DirectoryEntry(sLdapPath, _dirnode.LdapContext.UserName, _dirnode.LdapContext.Password);
                        if (entry == null)
                        {
                            return;
                        }
                        ADUCDirectoryNode dn = new ADUCDirectoryNode(
                            sDn,
                            _dirnode.LdapContext,
                            _dirnode.ObjectClass,
                            Properties.Resources.computer,
                            _dirnode.t,
                            _dirnode.Plugin,
                            _dirnode.IsDisabled);
                        string primaryDn = UserGroupUtils.GetPrimaryGroup(dn);
                        if (primaryDn != null && primaryDn.Trim().Equals(_dirnode.DistinguishedName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            string Msg =
                                "This is the member's primary group, so the member cannot be removed. " +
                                "Go to the Member Of tab of \n" +
                                "the member's property sheet and set another group " +
                                "as primary. You can then remove the member from this group";
                            container.ShowError(Msg);
                            return;
                        }

                        ListViewItem[]      lvItemArr  = new ListViewItem[MemoflistView.Items.Count - 1];
                        List <ListViewItem> lvItemList = new List <ListViewItem>();
                        int i = 0;

                        foreach (ListViewItem lvitem in MemoflistView.Items)
                        {
                            if (!lvitem.Equals(item))
                            {
                                lvItemList.Add(lvitem);
                            }
                        }
                        foreach (ListViewItem lvitem in lvItemList)
                        {
                            lvItemArr[i++] = lvitem;
                        }

                        MemoflistView.Items.Clear();
                        MemoflistView.Items.AddRange(lvItemArr);

                        ModifiedObjects.Remove((item.Tag as string).ToLower());
                        memListchanged = true;
                    }
                    RemoveButton.Enabled = false;
                }
            }
            else
            {
                memListchanged = false;
            }

            UpdateApplyButton();
        }
Пример #20
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("Disconnect &All Open Files"))
            {
                DialogResult dlg = MessageBox.Show(this, "Are you sure you wish to close all files?",
                                                   CommonResources.GetString("Caption_Console"),
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.None,
                                                   MessageBoxDefaultButton.Button1);

                if (dlg == DialogResult.OK)
                {
                    Hostinfo hn = ctx as Hostinfo;

                    foreach (ListViewItem Item in lvFilePage.Items)
                    {
                        string sFileId = (string)Item.SubItems[4].Text;

                        try
                        {
                            int nFileId = int.Parse(sFileId);

                            if (plugin.fileHandle != null)
                            {
                                SharesAPI.CloseFile(IntPtr.Zero, hn.creds, hn.hostName, nFileId);
                            }
                            else
                            {
                                SharesAPI.CloseFile(plugin.fileHandle.Handle, hn.creds, hn.hostName, nFileId);
                            }
                        }
                        catch (Exception ex)
                        {
                            string sMsg = string.Format(Resources.Error_UnableToCloseFile, ex.Message);
                            container.ShowError(sMsg);
                            break;
                        }
                    }
                    //Just do refresh once the files got closed on the treenode.
                    treeNode.sc.ShowControl(treeNode);
                }
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }
        }
 public AssertionFailedException(string description)
     : base(CommonResources.GetString(CommonResources.ShipAssertExceptionMessage, description))
 {
 }
Пример #22
0
        private void LMCMainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (sc.manage.rootNode.Nodes.Count == 0)
            {
                return;
            }

            e.Cancel = true;

            FormCollection openForms = Application.OpenForms;

            if (openForms != null && openForms.Count != 1)
            {
                foreach (Form f in openForms)
                {
                    MessageBox.Show("An open form exists");
                }

                string sMsg = "You must close all dialog boxes before you can close the Administrative Console.";
                MessageBox.Show(this, sMsg, CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Error);

                foreach (Form f in openForms)
                {
                    f.BringToFront();
                }

                return;
            }

            try
            {
                if (IsSetingsCanSave)
                {
                    DialogResult dlg = MessageBox.Show(this, string.Format(Resources.SaveSettingsMessage, FormatFilePath(_fileName)), "Likewise Management Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
                    if (dlg == DialogResult.Yes)
                    {
                        e.Cancel = true;

                        if (OpenSaveDialogToSaveSettings())
                        {
                            e.Cancel = false;

                            this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.LMCMainForm_FormClosing);
                            Application.Exit();
                        }
                    }
                    else if (dlg == DialogResult.No)
                    {
                        this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.LMCMainForm_FormClosing);
                        Close();
                        Application.Exit();
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
                else
                {
                    this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.LMCMainForm_FormClosing);
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("LMCMainForm.LMCMainForm_FormClosing()", ex);
            }
        }
Пример #23
0
        private static string UpdatePluginToConsole(string args)
        {
            string sConsolePath = string.Empty;

#if QUARTZ
            sConsolePath = Application.StartupPath;
            sConsolePath = Path.Combine(sConsolePath, "iConsole.lmc");

            XmlDocument XmlDoc = new XmlDocument();
            try
            {
                XmlDoc.LoadXml(CommonResources.GetString("ConsoleSettings"));
                if (XmlDoc != null)
                {
                    XmlElement ViewsNode = (XmlElement)XmlDoc.GetElementsByTagName("Views")[0];
                    if (ViewsNode != null)
                    {
                        string dllsPath = "Likewise.LMC.Plugins";
                        string name     = string.Empty;

                        XmlElement viewNode = ViewsNode.OwnerDocument.CreateElement("View");
                        viewNode.SetAttribute("NodeID", "0");
                        switch (args)
                        {
                        case "aduc":
                            name     = "ADUCPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.dll", name));
                            break;

                        case "cellmanager":
                            name     = "CellManagerPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.dll", name));
                            break;

                        //Commented since GPOE plugin is not an independent plugin to open it directly.
                        //Since it has it own requirement to connect to the domain before plugin to be added
                        //case "gpoe":
                        //    name = "GPOEPlugin";
                        //    dllsPath = string.Concat(dllsPath, string.Format(".{0}.dll", name));
                        //    break;

                        case "gpmc":
                            name     = "GPMCPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.dll", name));
                            break;

                        case "fileandprint":
                            name     = "FileAndPrint";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.dll", name));
                            break;

                        case "lug":
                            name     = "LUGPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.unix.dll", name));
                            break;

                        case "lsa":
                            name     = "LSAMgmtPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.unix.dll", name));
                            break;

                        case "kerberos":
                            name     = "KerberosKeyTableMgmtPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.unix.dll", name));
                            break;

                        case "auth":
                            name     = "AuthPlugIn";
                            dllsPath = string.Format("{0}.unix.dll", name);
                            break;

                        case "eventviewer":
                            name     = "EventlogPlugin";
                            dllsPath = string.Concat(dllsPath, string.Format(".{0}.dll", name));
                            break;

                        default:
                            sConsolePath = null;
                            break;
                        }

                        XmlElement hostInfo = viewNode.OwnerDocument.CreateElement("HostInfo");

                        viewNode.SetAttribute("NodeName", name);
                        viewNode.SetAttribute("NodeDll", dllsPath);

                        viewNode.AppendChild(hostInfo);
                        ViewsNode.AppendChild(viewNode);
                    }
                }
                XmlDoc.Save(sConsolePath);
            }
            catch (Exception e)
            {
                Logger.LogException("LMCAppMain.cs: UpdatePluginToConsole", e);
            }
#endif
            return(sConsolePath);
        }
Пример #24
0
        private static void Main(string[] args)
        {
            // LdapTest.testing();

            string sConsoleFile = null;

            if (args.Length == 1 && !args[0].StartsWith("--"))
            {
                sConsoleFile = args[0];
            }

            // Enable themes
            Application.EnableVisualStyles();

            // Set the user interface to display in the
            // same culture as that set in Control Panel.
            Thread.CurrentThread.CurrentUICulture =
                Thread.CurrentThread.CurrentCulture;

            try
            {
                // process command line args
                if (args.Length > 0 && args[0].StartsWith("--"))
                {
                    parseCommandLineArgs(args, out sConsoleFile);
                }

                if (Configurations.currentPlatform == LikewiseTargetPlatform.Unknown)
                {
                    Configurations.determineTargetPlatform();
                }
                Configurations.setPlatformFeatures();
                Configurations.verifyEnvironment();

                Logger.Log("Likewise Management Console started");
                Logger.Log("Current LogLevel = " + Logger.currentLogLevel);

                //make sure a local, persistent, user-writeable data path exists.
                if (!System.IO.Directory.Exists(Application.UserAppDataPath))
                {
                    System.IO.Directory.CreateDirectory(Application.UserAppDataPath);
                }

                Hostinfo hnTemp = new Hostinfo();

                // create a mainform, show it and peg it
                LMCMainForm mf = new LMCMainForm(sConsoleFile);

                // Display the real form
                mf.TopLevel = true;
                mf.Show();

                // hide the splash window since we're getting ready to show a real one
                mf.Activate();

                // start running
                Application.Run(mf);
            }
            catch (ShowUsageException)
            {
            }
            catch (DllNotFoundException ex)
            {
                Logger.LogMsgBox(String.Format(
                                     "Likewise Management Console encountered a fatal error: Could not find DLL: {0}",
                                     ex.Message));
                Logger.Log(String.Format("EXCEPTION (caught in LMCAppMain.cs): \n{0}",
                                         ex), Logger.LogLevel.Panic);
            }
            catch (Exception ex)
            {
                int ex_id = 0;
                MessageBox.Show("Likewise Management Console encountered a fatal error.",
                                CommonResources.GetString("Caption_Console"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                Logger.Log(String.Format("EXCEPTION #{0} (caught in LMCAppMain.cs): \n{1}",
                                         ex_id++, ex), Logger.LogLevel.Panic);

                for (Exception in_ex = ex.InnerException; in_ex != null; in_ex = in_ex.InnerException)
                {
                    Logger.Log(String.Format(
                                   "\n\nEXCEPTION #{0}: \n{1}", ex_id++, in_ex), Logger.LogLevel.Panic);
                }
            }

            //Only in the debug build, make sure all the unmanaged objects have been freed
#if DEBUG
            Likewise.LMC.Utilities.DebugMarshal.CheckAllFreed();
#endif

            return;
        }
Пример #25
0
        /// <summary>
        /// Modifies the specified attributes for the selected AD Object either "user" to AD Schema template
        /// </summary>
        /// <returns></returns>
        public bool OnApply()
        {
            List <LDAPMod> ldapAttrlist = new List <LDAPMod>();
            List <LDAPMod> attrlist     = new List <LDAPMod>();

            if (dirnode == null ||
                String.IsNullOrEmpty(dirnode.DistinguishedName) ||
                dirnode.LdapContext == null)
            {
                return(true);
            }

            if (ListUserOptions.GetItemChecked(0) && ListUserOptions.GetItemChecked(1))
            {
                string Msg = "You cannot select both 'User must change passowrd at next logon' and 'User cannot change password'\nfor the same user";
                MessageBox.Show(this, Msg, CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                ListUserOptions.SetItemChecked(1, false);
                return(false);
            }

            if (ListUserOptions.GetItemChecked(0) && ListUserOptions.GetItemChecked(2))
            {
                string Msg = "You have selected 'Password never expires'. \nThe user will not be required to change the password at next logon.";
                MessageBox.Show(this, Msg, CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                ListUserOptions.SetItemChecked(0, false);
                return(false);
            }

            //the following portion of code uses openldap "ldap_Modify_s"
            string           basedn     = dirnode.DistinguishedName;
            DirectoryContext dirContext = dirnode.LdapContext;

            string[] objectClass_values = null;

            if (Logonname != null && !(Logonname.Trim().Equals(txtlogon.Text.Trim())))
            {
                objectClass_values = new string[] { txtlogon.Text.Trim(), null };
                LDAPMod attr =
                    new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "userPrincipalName",
                                objectClass_values);
                attrlist.Add(attr);
            }

            if (txtpreLogonname.Text.Trim().Length > 0 && !(PreLogonname.Trim().Equals(txtpreLogonname.Text.Trim())))
            {
                objectClass_values = new string[] { txtpreLogonname.Text.Trim(), null };
                LDAPMod attr =
                    new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "sAMAccountName",
                                objectClass_values);
                attrlist.Add(attr);
            }
            if (dateTimePicker.Enabled && dateTimePicker.Value != null)
            {
                objectClass_values = new string[] { ConvertToUnixTimestamp(dateTimePicker.Value).ToString(), null };
                LDAPMod attr =
                    new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "accountExpires",
                                objectClass_values);
                attrlist.Add(attr);
            }

            if (!String.IsNullOrEmpty(pwdLastSet))
            {
                objectClass_values = new string[] { pwdLastSet, null };
                LDAPMod attr =
                    new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "pwdLastSet",
                                objectClass_values);
                attrlist.Add(attr);
            }

            //userWorkstations attribute
            if (String.IsNullOrEmpty(sUserWorkStations))
            {
                objectClass_values = new string[] { null }
            }
            ;
            else
            {
                objectClass_values = new string[] { sUserWorkStations, null }
            };
            LDAPMod attri =
                new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "userWorkstations",
                            objectClass_values);

            attrlist.Add(attri);

            if (ListUserOptions.SelectedIndices.Count > 0)
            {
                objectClass_values = new string[] { CalculateUserAccountControl().ToString(), null };
                LDAPMod attr =
                    new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "userAccountControl",
                                objectClass_values);
                attrlist.Add(attr);
            }

            LDAPMod[] attrArry = attrlist.ToArray();
            int       ret      = -1;

            if (attrArry != null && attrArry.Length != 0)
            {
                ret = dirContext.ModifySynchronous(basedn, attrArry);
            }
            else
            {
                return(true);
            }
            if (ret != 0)
            {
                string sMsg = ErrorCodes.LDAPString(ret);
                container.ShowError(sMsg);
                return(false);
            }
            else
            {
                DirectoryEntry de = new DirectoryEntry(dirnode.DistinguishedName);
                de.Properties["pwdLastSet"].Value = pwdLastSet;
                de.CommitChanges();
            }
            return(true);
        }
 private void ShowUserMessage(string msg)
 {
     MessageBox.Show(this, msg, CommonResources.GetString("Caption_Console"), MessageBoxButtons.OK);
     return;
 }
        public void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi.Text.Trim().Equals("&Refresh"))
            {
                treeNode.IsModified = true;
                treeNode.sc.ShowControl(treeNode);
                return;
            }
            else if (mi.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }
            else if (mi.Text.Trim().Equals("&Properties"))
            {
                ServicePropertiesDlg dlg = new ServicePropertiesDlg(base.container, this, plugin, serviceInfo.serviceName.Trim());
                dlg.ShowDialog();

                if (dlg.commit)
                {
                    treeNode.IsModified = true;
                    treeNode.sc.ShowControl(treeNode);
                    return;
                }
            }
            else
            {
                if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                {
                    switch (mi.Text.Trim())
                    {
                    case "&Restart":
                        ServiceManagerWindowsWrapper.WMIServiceRestart(serviceInfo.serviceName);
                        break;

                    default:
                        Do_WinServiceInvoke(mi.Text.Trim());
                        break;
                    }
                }
                else
                {
                    int    iRet    = 0;
                    IntPtr pHandle = ServiceManagerInteropWrapper.ApiLwSmAcquireServiceHandle(mi.Tag as string);
                    switch (mi.Text.Trim())
                    {
                    case "&Restart":
                        if (pHandle != IntPtr.Zero)
                        {
                            iRet = ServiceManagerInteropWrapper.ApiLwSmRefreshService(pHandle);
                        }
                        break;

                    case "&Start":
                        if (pHandle != IntPtr.Zero)
                        {
                            ServiceManagerInteropWrapper.StartAllServiceDependencies(pHandle, ref iRet);
                        }
                        break;

                    case "&Stop":
                        if (pHandle != IntPtr.Zero)
                        {
                            iRet = ServiceManagerInteropWrapper.StopServiceRecursive(pHandle);
                        }
                        break;

                    default:
                        break;
                    }
                    if (iRet == (int)41202)
                    {
                        container.ShowError("The service is unable to start.\nPlease check the all its dependencies are started");
                    }
                    else if (iRet != 0)
                    {
                        container.ShowError("Failed to start the specified service: error code:" + iRet);
                    }

                    ServiceManagerInteropWrapper.ApiLwSmReleaseServiceHandle(pHandle);

                    if (iRet == 0)
                    {
                        treeNode.IsModified = true;
                        treeNode.sc.ShowControl(treeNode);
                        return;
                    }
                }
            }
        }
Пример #28
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int    ret      = -1;
            int    i        = 0;
            string lname    = string.Empty;
            bool   Isexists = false;

            lname     = this.renameUserInfo.logonName;
            logonname = this.logonNametextBox.Text.Trim() + "@" + _dirnode.LdapContext.DomainName;

            if (string.Compare(lname, logonname) != 0)
            {
                while (i < logonname.Length)
                {
                    if (Char.IsControl(logonname[i]) || (logonname[i] == '/') || (logonname[i] == '\\') ||
                        (logonname[i] == '[') || (logonname[i] == ']') || (logonname[i] == ':') || (logonname[i] == ';') ||
                        (logonname[i] == '|') || (logonname[i] == '=') || (logonname[i] == ',') || (logonname[i] == '+') ||
                        (logonname[i] == '*') || (logonname[i] == '?') || (logonname[i] == '<') || (logonname[i] == '>') ||
                        (logonname[i] == '"'))
                    {
                        Isexists = true;
                        break;
                    }
                    else
                    {
                        i++;
                    }
                }
                if (Isexists)
                {
                    DialogResult dlg = MessageBox.Show(
                        this,
                        "The pre-Windows 2000 logon name " +
                        logonname +
                        " contains one or more of the following illegal characters " +
                        ":/\\n []:;|=,*+?<> \n If you continue LAC will replace these " +
                        "characters with underscore ('_').\n Do you want to continue?",
                        CommonResources.GetString("Caption_Console"),
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Exclamation);
                    if (dlg == DialogResult.Yes)
                    {
                        i = 0;
                        while (i < logonname.Length)
                        {
                            if (Char.IsControl(logonname[i]) || (logonname[i] == '/') || (logonname[i] == '\\') ||
                                (logonname[i] == '[') || (logonname[i] == ']') || (logonname[i] == ':') || (logonname[i] == ';') ||
                                (logonname[i] == '|') || (logonname[i] == '=') || (logonname[i] == ',') || (logonname[i] == '+') ||
                                (logonname[i] == '*') || (logonname[i] == '?') || (logonname[i] == '<') || (logonname[i] == '>') ||
                                (logonname[i] == '"'))
                            {
                                logonname = logonname.Replace(logonname[i], '_');
                            }
                            else
                            {
                                i++;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                string           filterquery = string.Format("(&(objectClass=user)(userPrincipalName={0}))", logonname);
                List <LdapEntry> ldapEntries = null;

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

                ret = _dirnode.LdapContext.ListChildEntriesSynchronous(
                    _dirnode.LdapContext.RootDN,
                    Likewise.LMC.LDAP.Interop.LdapAPI.LDAPSCOPE.SUB_TREE,
                    filterquery,
                    attrList,
                    false,
                    out ldapEntries);
                if (ldapEntries != null && ldapEntries.Count != 0)
                {
                    string sMsg = "The user logon name you have choosen is already in use in this enterprise.\n" +
                                  "Choose another logon name, and try again";
                    MessageBox.Show(this, sMsg, CommonResources.GetString("Caption_Console"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                this.renameUserInfo.logonName = logonname;
            }

            if (string.Compare(this.renameUserInfo.fullName, this.FullNametextbox.Text.Trim()) != 0)
            {
                string           filterqry = string.Format("(&(objectClass=user)(name={0}))", this.FullNametextbox.Text.Trim());
                List <LdapEntry> ldapEntry = null;

                string[] attrLists = new string[]
                {
                    "objectClass", null
                };

                ret = _dirnode.LdapContext.ListChildEntriesSynchronous(
                    ParentDN,
                    Likewise.LMC.LDAP.Interop.LdapAPI.LDAPSCOPE.ONE_LEVEL,
                    filterqry,
                    attrLists,
                    false,
                    out ldapEntry);
                if (ldapEntry != null && ldapEntry.Count != 0)
                {
                    string sMsg = string.Format("LAC cannot complete the rename operation on {0} because:" +
                                                "\nAn attempt was made to add an object to the directory with a name that is already in use." +
                                                "\n\nName-related properties on this object might now be out of sync. Contact your system administrator.",
                                                this.renameUserInfo.fullName);

                    MessageBox.Show(this, sMsg, CommonResources.GetString("Caption_Console"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                this.renameUserInfo.fullName = this.FullNametextbox.Text.Trim();
            }

            this.renameUserInfo.commit = true;
            this.Close();
        }
Пример #29
0
        public override string OnWizardNext()
        {
            int    ret      = -1;
            int    i        = 0;
            string prename  = "";
            bool   Isexists = false;

            prename   = this._userAddDlg.userInfo.userPrelogonname;
            logonname = this.logonNametextBox.Text.Trim() + "@" + this._userAddDlg.userInfo.domainName;

            while (i < prename.Length)
            {
                if (Char.IsControl(prename[i]) || (prename[i] == '/') || (prename[i] == '\\') ||
                    (prename[i] == '[') || (prename[i] == ']') || (prename[i] == ':') || (prename[i] == ';') ||
                    (prename[i] == '|') || (prename[i] == '=') || (prename[i] == ',') || (prename[i] == '+') ||
                    (prename[i] == '*') || (prename[i] == '?') || (prename[i] == '<') || (prename[i] == '>') ||
                    (prename[i] == '"') || (prename[i] == '@'))
                {
                    Isexists = true;
                    break;
                }
                else
                {
                    i++;
                }
            }
            if (Isexists)
            {
                DialogResult dlg = MessageBox.Show(
                    this,
                    "The pre-Windows 2000 logon name " +
                    prename +
                    " contains one or more of the following illegal characters " +
                    ":/\\n []:;|=,*+?<>@\" \n If you continue LAC will replace these " +
                    "characters with underscore ('_').\n Do you want to continue?",
                    CommonResources.GetString("Caption_Console"),
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation);
                if (dlg == DialogResult.Yes)
                {
                    i = 0;
                    while (i < prename.Length)
                    {
                        if (Char.IsControl(prename[i]) || (prename[i] == '/') || (prename[i] == '\\') ||
                            (prename[i] == '[') || (prename[i] == ']') || (prename[i] == ':') || (prename[i] == ';') ||
                            (prename[i] == '|') || (prename[i] == '=') || (prename[i] == ',') || (prename[i] == '+') ||
                            (prename[i] == '*') || (prename[i] == '?') || (prename[i] == '<') || (prename[i] == '>') ||
                            (prename[i] == '"') || (prename[i] == '@'))
                        {
                            prename = prename.Replace(prename[i], '_');
                        }
                        else
                        {
                            i++;
                        }
                    }
                }
                else
                {
                    return(WizardDialog.NoPageChange);
                }
            }
            this._userAddDlg.userInfo.logonName        = logonname;
            this._userAddDlg.userInfo.userPrelogonname = prename;
            string           filterquery = string.Format("(&(objectClass=user)(userPrincipalName={0}))", logonname);
            List <LdapEntry> ldapEntries = null;

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

            ret = _dirnode.LdapContext.ListChildEntriesSynchronous(
                _dirnode.LdapContext.RootDN,
                Likewise.LMC.LDAP.Interop.LdapAPI.LDAPSCOPE.SUB_TREE,
                filterquery,
                attrList,
                false,
                out ldapEntries);
            if (ldapEntries != null && ldapEntries.Count != 0)
            {
                string sMsg = "The user logon name you have choosen is already in use in this enterprise.\n" +
                              "Choose another logon name, and try again";
                MessageBox.Show(this, sMsg, CommonResources.GetString("Caption_Console"),
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(WizardDialog.NoPageChange);
            }

            return(base.OnWizardNext());
        }
        private bool ValidateEntries(int iMode)
        {
            string sResult = "", sTemp = "", sErrorMsg = "";
            int    iWidth = 0, iMaxVal = 0;
            bool   bValid  = true;
            Regex  regHexa = new Regex("^[\\s0-9A-F]{2}$");
            Regex  regOct  = new Regex("^[\\s0-7]{3}$");
            Regex  regDeci = new Regex("^[\\s0-9]{3}$");
            Regex  regBin  = new Regex("^[\\s0-1]{8}$");

            try
            {
                rtbAttr.Text = rtbAttr.Text.Trim();
                if (rtbAttr.Text.Trim().Equals("<Not Set>", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
                switch (iMode)
                {
                case 16:     //Hexa
                    #region Hexa
                    iWidth = 2;
                    for (int i = 0; i < rtbAttr.Text.Length;)
                    {
                        if (i + iWidth > rtbAttr.Text.Length)
                        {
                            sTemp = rtbAttr.Text.Substring(i);
                        }
                        else
                        {
                            sTemp = rtbAttr.Text.Substring(i, iWidth);
                        }

                        if (!regHexa.IsMatch(sTemp) ||
                            (sTemp.ToString().Trim().Equals(string.Empty) && sTemp.Length > 1))
                        {
                            bValid    = false;
                            sErrorMsg = "Invalid format. A hexadecimal string must contain sets of two digits \nbetween 0 and FF. Each set must be separated by a space, e.g.,'01 11 AB F1'.";
                            break;
                        }
                        else
                        {
                            sResult += " " + sTemp.Trim().PadLeft(iWidth, '0');
                        }
                        i += (iWidth + 1);
                    }
                    break;

                    #endregion Hexa
                case 8:     //Octal
                    #region Octal
                    iWidth  = 3;
                    iMaxVal = 377;
                    for (int i = 0; i < rtbAttr.Text.Length;)
                    {
                        if (i + iWidth > rtbAttr.Text.Length)
                        {
                            sTemp = rtbAttr.Text.Substring(i);
                        }
                        else
                        {
                            sTemp = rtbAttr.Text.Substring(i, iWidth);
                        }

                        if (!regOct.IsMatch(sTemp) || (Convert.ToInt16(sTemp.Trim()) > iMaxVal) ||
                            (sTemp.ToString().Trim().Equals(string.Empty) && sTemp.Length > 1))
                        {
                            bValid    = false;
                            sErrorMsg = "Invalid format. A Octal string must contain sets of three digits \nbetween 0 and 377. Each set must be separated by a space, e.g.,'022 151 377 005'.";
                            break;
                        }
                        else
                        {
                            sResult += " " + sTemp.Trim().PadLeft(iWidth, '0');
                        }
                        i += (iWidth + 1);
                    }
                    break;

                    #endregion Octal
                case 10:     //Decimal
                    #region Decimal
                    iWidth  = 3;
                    iMaxVal = 255;
                    for (int i = 0; i < rtbAttr.Text.Length;)
                    {
                        if (i + iWidth > rtbAttr.Text.Length)
                        {
                            sTemp = rtbAttr.Text.Substring(i);
                        }
                        else
                        {
                            sTemp = rtbAttr.Text.Substring(i, iWidth);
                        }

                        if ((!regDeci.IsMatch(sTemp)) ||
                            (sTemp.ToString().Trim().Equals(string.Empty) && sTemp.Length > 1))
                        {
                            bValid    = false;
                            sErrorMsg = "Invalid format. A Decimal string must contain sets of three digits \nbetween 0 and 255. Each set must be separated by a space, e.g.,'051 211 255 009'.";
                            break;
                        }
                        else
                        {
                            sResult += " " + sTemp.Trim().PadLeft(iWidth, '0');
                        }
                        i += (iWidth + 1);
                    }
                    break;

                    #endregion Decimal
                case 2:     //Binary
                    #region Binary
                    iWidth = 8;
                    for (int i = 0; i < rtbAttr.Text.Length;)
                    {
                        if (i + iWidth > rtbAttr.Text.Length)
                        {
                            sTemp = rtbAttr.Text.Substring(i);
                        }
                        else
                        {
                            sTemp = rtbAttr.Text.Substring(i, iWidth);
                        }

                        if ((!regBin.IsMatch(sTemp)) ||
                            (sTemp.ToString().Trim().Equals(string.Empty) && sTemp.Length > 1))
                        {
                            bValid    = false;
                            sErrorMsg = "Invalid format. A Binary string must contain sets of \neight binary digits between '00000000' and '11111111'. \nEach set must be separated by a space, e.g.,'00110011 11111111'.";
                            break;
                        }
                        else
                        {
                            sResult += " " + sTemp.Trim().PadLeft(iWidth, '0');
                        }
                        i += (iWidth + 1);
                    }
                    break;
                    #endregion Binary
                }
                if (bValid)
                {
                    rtbAttr.Text = sResult.ToString().Trim();
                    return(true);
                }
                else
                {
                    MessageBox.Show(
                        this,
                        sErrorMsg,
                        CommonResources.GetString("Caption_Console"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("OctetStringAttributeEditor.ValidateEntries", ex);
                return(false);
            }
        }