Exemplo n.º 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (_rightschanged)
     {
         //Если отредактированы права, но не сохранены - сохраняем
         lvUsers_SelectedIndexChanged(null, null);
     }
     ADUserPicker au = new ADUserPicker();
     au.Filter = 3;
     if (au.ShowDialog() == DialogResult.OK)
     {
         if (_remoteusers.GetItem(au.UserSid) != null)
         {
             MessageBox.Show("Указанный пользователь уже имеется в списке");
         }
         else
         {
             NTUsersItem nu = new NTUsersItem();
             nu.Sid = au.UserSid;
             //nu.Name = au.UserName;
             nu.Allow = 0x01ff; //Allow all
             _remoteusers.Items.Add(nu);
         }
     }
     au.Dispose();
     UpdateUsersList();
 }
Exemplo n.º 2
0
 private void btnDeleteUser_Click(object sender, EventArgs e)
 {
     if (lvUsers.SelectedItems.Count > 0)
     {
         NTUsersItem nu = _remoteusers.GetItem(lvUsers.SelectedItems[0].Tag.ToString());
         _remoteusers.Items.Remove(nu);
         UpdateUsersList();
     }
 }
Exemplo n.º 3
0
        public int Parse(byte[] data)
        {
            int count = 0;

            //Парсим информацию из реестра
            for (int i = 0; i < data.Length; i += 40)
            {
                //Если нет сигнатуры 0x24 то нам подсунули что-то иное, а не NtUsers!
                if (data[i + 3] != 0x24)
                {
                    break;
                }
                UInt16 rights = (UInt16)((data[i + 8]) + (data[i + 9] << 8));
                //Разрешающие (true) или запрещающие (false) права
                bool   _righttype = ((data[i + 4]) == 1) ? false : true;
                byte[] _sidhex    = new byte[24];
                for (int j = 0; j < 24; j++)
                {
                    _sidhex[j] = data[i + j + 16];
                }
                bool        found = false;
                NTUsersItem _ntu  = null;
                foreach (NTUsersItem _nu in _list)
                {
                    //if (_nu.Hex == _sidhex)
                    if (CompareArray(_nu.Hex, _sidhex))
                    {
                        _ntu  = _nu;
                        found = true;
                        break;
                    }
                }
                if (_ntu == null)
                {
                    _ntu     = new NTUsersItem();
                    _ntu.Hex = _sidhex;
                }
                if (_righttype)
                {
                    _ntu.Allow = rights;
                }
                else
                {
                    _ntu.Deny = rights;
                }
                if (!found)
                {
                    _list.Add(_ntu);
                    count++;
                }
            }
            return(count);
        }
Exemplo n.º 4
0
        public NTUsersItem GetItem(string sid)
        {
            NTUsersItem result = null;

            foreach (NTUsersItem nu in _list)
            {
                if (nu.Sid == sid)
                {
                    result = nu;
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public int OpenFile(string Name)
        {
            _remoteusers.Items.Clear();
            cbNTAuthEnabled.Checked = false;
            cbDisableAudio.Checked = false;
            cbDisableChat.Checked = false;
            cbDisableFile.Checked = false;
            cbDisableMessage.Checked = false;
            cbDisableRedirect.Checked = false;
            cbDisableScreen.Checked = false;
            cbDisableShutdown.Checked = false;
            cbDisableTelnet.Checked = false;
            cbDisableView.Checked = false;
            cbEnableEventLog.Checked = false;
            cbEnableLogFile.Checked = false;
            tbPort.Text = "4899";
            tbTrayIconMode.Text = "2"; 
            tbTimeout.Text = "10";   
            int result = -1;//общая ошибка
            XmlDocument document = new XmlDocument();
            try
            {
                document.Load(Name);
                XmlNode node = document.SelectSingleNode("/Rage/Version");
                if (Convert.ToInt32(node.InnerText) != 1)
                {
                    //не поддерживаемая версия
                    return -2;
                }
                node = document.SelectSingleNode("/Rage/NTAuthEnabled");
                cbNTAuthEnabled.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableAudio");
                cbDisableAudio.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableChat");
                cbDisableChat.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableFile");
                cbDisableFile.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableMessage");
                cbDisableMessage.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableRedirect");
                cbDisableRedirect.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableScreen");
                cbDisableScreen.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableShutdown");
                cbDisableShutdown.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableTelnet");
                cbDisableTelnet.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/DisableView");
                cbDisableView.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/EnableEventLog");
                cbEnableEventLog.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/EnableLogFile");
                cbEnableLogFile.Checked = Convert.ToBoolean(node.InnerText);
                node = document.SelectSingleNode("/Rage/Port");
                tbPort.Text = node.InnerText;
                node = document.SelectSingleNode("/Rage/TrayIconMode");
                tbTrayIconMode.Text = node.InnerText;
                node = document.SelectSingleNode("/Rage/Timeout");
                tbTimeout.Text = node.InnerText;
                XmlNodeList nodes = document.SelectNodes("/Rage/NtUser/User");

                foreach (XmlNode nd in nodes)
                {
                    NTUsersItem nu = new NTUsersItem();
                    nu.Sid = nd.Attributes.GetNamedItem("Sid").InnerText;
                    nu.Allow = Convert.ToUInt16(nd.Attributes.GetNamedItem("Allow").InnerText);
                    nu.Deny = Convert.ToUInt16(nd.Attributes.GetNamedItem("Deny").InnerText);
                    _remoteusers.Items.Add(nu);
                }
                result = 0;
            }
            catch { }
            return result;
        }