Beispiel #1
0
        private void textUMManager_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (textUMManager.Text != "N/A")
            {
                string name = textUMManager.Text.Replace("Not found - ", "").Replace("Term - ", "");
                if (textUMManager.Text != null && textUMManager.Text != "")
                {
                    if (textUMManager.Text.Contains("Not found"))
                    {
                        MessageBox.Show("User not found in Active or Terminated user lists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (textUMManager.Text.Contains("Term"))
                    {
                        checkUMTerminatedUsers.Checked = true;
                    }
                    Refresh();

                    try {
                        SearchResult res = ADS.GetSingleUser(name);

                        if (res == null)
                        {
                            res = ADS.GetTerminatedUser(name);
                        }
                        if (res == null)
                        {
                            res = ADS.GetEXUser(name);
                        }
                        if (res != null)
                        {
                            List <string> temp = ADS.PopulateUserList(checkUMTerminatedUsers.Checked);
                            temp.Add(res.Properties["samaccountname"][0].ToString());
                            comboUMUserSelect.DataSource = temp;
                        }

                        comboUMUserSelect.Text = res.Properties["samaccountname"][0].ToString();
                        ActiveControl          = labelUMUserSelect;
                    } catch (Exception ex) {
                        MessageBox.Show($"Could not resolve user identity.  Please select through main user dropdown.\r\n\r\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Parses user's Manager value (DistinguishedName) into Manager's Display Name.
        /// </summary>
        /// <param name="user">SearchResult of user with Manager to parse.</param>
        /// <returns>String value of Manager's Display Name.</returns>
        private string GetUserManager(SearchResult user)
        {
            string managername;

            try {
                managername = (string)ADS.GetSingleUser((string)user.Properties["manager"][0]).Properties["displayname"][0];
            } catch {
                try {
                    managername = $"Term - {(string)ADS.GetTerminatedUser ((string)user.Properties["manager"][0]).Properties["displayname"][0]}";
                } catch {
                    try {
                        managername = $"Not found - {user.Properties["manager"][0].ToString ().Split (',')[0].Substring (3)}";
                    } catch {
                        managername = "Not Listed";
                    }
                }
            }
            return(managername);
        }
Beispiel #3
0
        /// <summary>
        /// Sets CurrentUser object with values necessary for usage in PMC processes.
        /// </summary>
        /// <param name="input">String input for passing into ADS.GetSingleUser and/or ADS.GetTerminatedUser.  Must be unique identifier or process will fail.</param>
        /// <param name="term">Boolean value determining whether or not to include Terminated users in search.</param>
        public void SetUser(string input, bool term)
        {
            //CurrentUser = ADS.searcher.FindOne ();
            if (input != null)
            {
                CurrentUser = ADS.GetSingleUser(input);

                if (term && CurrentUser == null)
                {
                    CurrentUser = ADS.GetTerminatedUser(input);
                }
                if (CurrentUser == null)
                {
                    CurrentUser = ADS.GetEXUser(input);
                }

                if (CurrentUser != null)
                {
                    userTools = UserPrincipal.FindByIdentity(ADS.context, Username);
                }
            }
        }