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()); }
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"; } }
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; } }
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()); }