コード例 #1
0
        private void cmbGroups_SelectedValueChanged(object sender, EventArgs e)
        {
            var domain = ((Domain)cmbDomains.SelectedItem);
            var users  = ActiveDirectoryServices.GetAllUserNamesByGroup(domain, cmbGroups.Text);

            this.cmbUserNames.Items.Clear();
            this.cmbUserNames.Items.AddRange(users.ToArray());
        }
コード例 #2
0
        private void AuthenticateUser()
        {
            ActiveDirectoryServices ads = new ActiveDirectoryServices();

            if (ActiveDirectoryServices.AuthenticateUser(cmbDomains.Text, cmbUserNames.Text, txtPassword.Text))
            {
                this.txtResult.Text = "True";
            }
            else
            {
                this.txtResult.Text = "Login failed";
            }
        }
コード例 #3
0
        public Form1()
        {
            this.InitializeComponent();
            this.cmbDomains.Items.AddRange(ActiveDirectoryServices.GetDomains().ToArray());
            var identity = System.Security.Principal.WindowsIdentity.GetCurrent();

            if (ValidateCurrentUser(identity))
            {
                var saveThisInTheDatabase = identity.User.Value;
                this.txtCurrentUser.Text  = identity.Name;
                this.txtUserIdentity.Text = saveThisInTheDatabase;
            }
        }
コード例 #4
0
        private void cmbDomains_SelectedValueChanged(object sender, EventArgs e)
        {
            this.cmbGroups.Enabled    = true;
            this.cmbUserNames.Enabled = true;
            this.txtPassword.Enabled  = true;

            var domain = ((Domain)cmbDomains.SelectedItem);

            var users  = ActiveDirectoryServices.GetAllUsers(domain);
            var groups = ActiveDirectoryServices.GetGroupNames(domain);

            this.cmbUserNames.Items.Clear();
            this.cmbUserNames.Items.AddRange(users.ToArray());

            this.cmbGroups.Items.Clear();
            this.cmbGroups.Items.AddRange(groups.ToArray());
        }