Example #1
0
        private void createGroupButton_Click(object sender, RoutedEventArgs e)
        {
            if (createGroupTextBox.Text.Contains("&") || createGroupTextBox.Text.Contains("/") || createGroupTextBox.Text.Contains("?") || createGroupTextBox.Text.Contains("\\"))
            {
                MessageBox1("'Group name' field contains an illegal character/s. If you anyway would like to create group with such name please use Crowd web interface");
                return;
            }



            if (createGroupTextBox.Text == "")
            {
                MessageBox1("Please fill the 'Group name' box first.");
                return;
            }
            getCredentials();
            string      createGroupURL = "/group";
            string      XmlDocument    = "<group name = \"" + createGroupTextBox.Text + "\" expand=\"attributes\"><type>GROUP</type><description>" + createGroupTextBox.Text + "</description><active>true</active><attributes><link rel =\"self\" href = \"/group?groupname=" + createGroupTextBox.Text + "\" /></attributes></group>";
            getResponse retrive        = new getResponse();
            string      data           = "";

            retrive.POST(serverURL + createGroupURL, XmlDocument, auth, out data);
            MessageBox1("'" + createGroupTextBox.Text + "' group was successfully created");
            GroupsTab();
            log("Create Group - " + createGroupTextBox.Text + " - Result: group successfully created");
        }
Example #2
0
        private void copyGroupsButton_Click(object sender, RoutedEventArgs e)
        {
            List <string> diffGroups  = new List <string>();
            string        XmlDocument = "";

            foreach (string group in listBoxSearchUser.Items)
            {
                if (listBox1.Items.Contains(group) == false)
                {
                    diffGroups.Add(group);
                }
            }



            if (diffGroups.Count != 0)
            {
                DialogBox DialogBox1 = new DialogBox();
                DialogBox1.Show("Group/s will be added. Would you like to continue?");
                if (DialogBox1.DialogResult == true)

                {
                    foreach (string group in diffGroups)
                    {
                        string      url     = serverURL + "/group?groupname=" + group;
                        getResponse retrive = new getResponse();
                        string      data    = "";
                        retrive.GET(url, auth0, out data);

                        if (data == "")

                        {
                            string createGroupURL = "/group";
                            XmlDocument = "<group name = \"" + group + "\" expand=\"attributes\"><type>GROUP</type><description>" + group + "</description><active>true</active><attributes><link rel =\"self\" href = \"/group?groupname=" + group + "\" /></attributes></group>";
                            retrive     = new getResponse();
                            data        = "";
                            retrive.POST(serverURL + createGroupURL, XmlDocument, auth0, out data);
                            log("Create Group - " + group + " - Result: group successfully created");
                        }

                        string addToGroupURL = "/user/group/direct?username="******"<group name=\"" + group + "\"/>";
                        retrive     = new getResponse();
                        data        = "";
                        retrive.POST(serverURL + addToGroupURL + userUnderProcess, XmlDocument, auth0, out data);
                        log("Add to Group - " + userUnderProcess + " - Result: was successfully added to the '" + group + "' group");
                        listBox1.Items.Add(group);
                    }
                }
            }


            this.DialogResult = true;
        }
        public void sendPassword()
        {
            try
            {
                string      sendPassword = "******";
                string      XmlDocument  = "";
                getResponse retrive      = new getResponse();
                string      data         = "";
                retrive.POST(serverURL + sendPassword + userName, XmlDocument, auth, out data);
            }

            catch (Exception ex)
            {
                MessageBox1(ex.Message);
            }
        }
Example #4
0
 private void addToGroupButton_Click(object sender, RoutedEventArgs e)
 {
     if (listBoxAvailibleGroups.SelectedItems.Count == 0)
     {
         MessageBox1("Please, select one or several groups first");
     }
     else
     {
         getCredentials();
         string addToGroupURL = "/user/group/direct?username="******"<group name=\"" + selectedGroup + "\"/>";
             getResponse retrive     = new getResponse();
             string      data        = "";
             retrive.POST(serverURL + addToGroupURL + UserNameBox.Text, XmlDocument, auth, out data);
             log("Add to Group - " + UserNameBox.Text + " - Result: was successfully added to the '" + selectedGroup + "' group");
         }
         MessageBox1("User '" + UserNameBox.Text + "' was successfully added to selected group/s");
         getUserGroup();
     }
 }
        private void recreateButton_Click(object sender, RoutedEventArgs e)
        {
            newDomain = targetDomainComboBox.Text;
            getCredentials(domain);

            if (userNameLabel.Content.ToString() == "")
            {
                MessageBox1("'User Name' field is empty");
                return;
            }

            DialogBox DialogBox1 = new DialogBox();

            DialogBox1.Show("User '" + userName + "' will be recreated in " + targetDomainComboBox.Text + " derictory. Would you like to continue?");

            if (DialogBox1.DialogResult == true)
            {
                string      removeUserURL = "/user?username="******"";

                retrive.DELETE(serverURL + removeUserURL, auth, out data);

                getCredentials(newDomain);

                try
                {
                    //create

                    string pass        = "******" + DateTime.Now.Millisecond.ToString() + "Epam";
                    string url         = serverURL + "/user";
                    string XmlDocument = "<user name=\"" + userName + "\" expand=\"attributes\"><first-name>" + firstName + "</first-name><last-name>" + lastName + "</last-name><display-name>" + firstName + " " + lastName + "</display-name><email>" + email + "</email><active>true</active><attributes><link rel=\"self\" href=\"/user/attribute?username="******"\"/></attributes><password><link rel=\"edit\" href=\"/user/password?username="******"\"/><value>" + pass + "</value></password></user>";
                    retrive = new getResponse();
                    data    = "";
                    retrive.POST(url, XmlDocument, auth, out data);
                    //set group

                    foreach (string group in userGroupsList)
                    {
                        string addToGroupURL = "/user/group/direct?username="******"<group name=\"" + group + "\"/>";
                        retrive     = new getResponse();
                        data        = "";
                        retrive.POST(serverURL + addToGroupURL + userName, XmlDocument, auth, out data);
                    }

                    sendPassword();
                    MessageBox1(userNameLabel.Content + " was successfully recreated in " + targetDomainComboBox.Text + " directory");
                    this.DialogResult = true;
                    log("Recreate - " + userNameLabel.Content + " was successfully recreated in " + targetDomainComboBox.Text + " directory");
                    Close();
                }



                catch
                (Exception ex)
                {
                    MessageBox1(ex.Message);
                }
            }
        }
Example #6
0
        private void CreateUpdateButton_Click(object sender, RoutedEventArgs e)
        {
            UserNameBox.Text  = UserNameBox.Text.TrimStart(' ').TrimEnd(' ');
            EmailBox.Text     = EmailBox.Text.TrimStart(' ').TrimEnd(' ');
            FirstNameBox.Text = FirstNameBox.Text.TrimStart(' ').TrimEnd(' ');
            LastNameBox.Text  = LastNameBox.Text.TrimStart(' ').TrimEnd(' ');
            getCredentials();

            if (CreateUpdateButton.Content == "Update")

            {
                if (UserNameBox.Text == "" || FirstNameBox.Text == "" || LastNameBox.Text == "" || EmailBox.Text == "")
                {
                    MessageBox1("Some of the mandatory fields are empty.");
                }
                else
                {
                    try
                    {
                        if (userName != UserNameBox.Text)
                        {
                            MessageBox1("This version of the application is not allowed to update 'User Name' field due to limitaions from the Atlassian Crowd side. https://jira.atlassian.com/browse/CWD-3388?src=confmacro If you anyway need this functionality please contact with Epam developers");
                            return;
                        }



                        if (ActiveCheckBox.IsChecked == true)
                        {
                            setActive = "true";
                        }
                        else
                        {
                            setActive = "false";
                        }
                        string      url         = serverURL + "/user?username="******"<user name=\"" + UserNameBox.Text + "\" expand=\"attributes\"><first-name>" + FirstNameBox.Text + "</first-name><last-name>" + LastNameBox.Text + "</last-name><display-name>" + FirstNameBox.Text + " " + LastNameBox.Text + "</display-name><email>" + EmailBox.Text + "</email><active>" + setActive + "</active><attributes><link rel=\"self\" href=\"/user/attribute?username="******"\"/></attributes><password><link rel=\"edit\" href=\"/user/password?username="******"\"/><value></value></password></user>";
                        getResponse retrive     = new getResponse();
                        string      data        = "";
                        retrive.PUT(url, XmlDocument, auth, out data);
                        MessageBox1("Updated successfully");
                        log("Update - " + UserNameBox.Text + " - Result: updated successfully");
                    }


                    catch

                    (Exception ex)
                    {
                        MessageBox1(ex.Message);
                    }
                }
            }

//Create User, send password link and assign to the jira-users group


            else
            {
                if (UserNameBox.Text == "" || FirstNameBox.Text == "" || LastNameBox.Text == "" || EmailBox.Text == "")
                {
                    MessageBox1("Some of the mandatory fields are empty.");
                }
                else
                {
                    try
                    {
//create

                        string pass = "******" + Convert.ToString(DateTime.Now.Millisecond) + "Epam";
                        if (ActiveCheckBox.IsChecked == true)
                        {
                            setActive = "true";
                        }
                        else
                        {
                            setActive = "false";
                        }
                        string      url         = serverURL + "/user";
                        string      XmlDocument = "<user name=\"" + UserNameBox.Text + "\" expand=\"attributes\"><first-name>" + FirstNameBox.Text + "</first-name><last-name>" + LastNameBox.Text + "</last-name><display-name>" + FirstNameBox.Text + " " + LastNameBox.Text + "</display-name><email>" + EmailBox.Text + "</email><active>" + setActive + "</active><attributes><link rel=\"self\" href=\"/user/attribute?username="******"\"/></attributes><password><link rel=\"edit\" href=\"/user/password?username="******"\"/><value>" + pass + "</value></password></user>";
                        getResponse retrive     = new getResponse();
                        string      data        = "";
                        retrive.POST(url, XmlDocument, auth, out data);

//set group
                        string addToGroupURL = "/user/group/direct?username="******"<group name=\"jira-users\"/>";
                        retrive     = new getResponse();
                        data        = "";
                        retrive.POST(serverURL + addToGroupURL + UserNameBox.Text, XmlDocument, auth, out data);

//send password

                        sendPassword();
                        MessageBox1("User '" + UserNameBox.Text + "' was successfully created and added to the 'jira-users' group. Email notification about the password sent to the " + EmailBox.Text);
                        log("Create - " + UserNameBox.Text + " - Result: successfully created in " + DirectoryComboBox.Text + " directory and added to the 'jira-users' group. Email notification about the password sent to: " + EmailBox.Text);
                        Clipboard.SetText("Account '" + UserNameBox.Text + "' was successfully created .Reset password link was sent to " + EmailBox.Text);
                        SearchButton_Click(sender, e);
                    }

                    catch
                    (Exception ex)
                    {
                        MessageBox1(ex.Message);
                    }
                }
            }
        }
Example #7
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            userName = "";
            foundUsers.Clear();
            maxIndex = 0;
            nextUserButton.Visibility = Visibility.Hidden;
            SearchTextBox.Text        = SearchTextBox.Text.TrimStart(' ').TrimEnd(' ');
// if field search is empty

            if (SearchTextBox.Text == "")
            {
                MessageBox1("Search field is empty.");
                return;
            }
// if master mode should be enabled
            if (SearchTextBox.Text == "#master")
            {
                DeleteUserButton.Visibility  = Visibility.Visible;
                deleteGroupButton.Visibility = Visibility.Visible;
                return;
            }



// User search

            string      xmlFile       = File.ReadAllText(Environment.CurrentDirectory + "\\application.conf");
            XmlDocument configuration = new XmlDocument();

            configuration.LoadXml(xmlFile);
            foreach (XmlNode tag in configuration.DocumentElement)
            {
                if (userName != "")
                {
                    return;
                }

                if (tag.Attributes["company"].Value == company)
                {
                    string directory = tag.Attributes["name"].Value;
                    serverURL = tag.Attributes["url"].Value + "/rest/usermanagement/1";
                    auth[0]   = tag.Attributes["user"].Value;
                    auth[1]   = tag.Attributes["password"].Value;
                    DirectoryComboBox.Text = directory;

// if string contains @ symbol do search by email address

                    if (SearchTextBox.Text.Contains("@") == true)
                    {
                        string      url         = serverURL + "/search?entity-type=user";
                        string      XmlDocument = "<property-search-restriction><property><name>email</name><type>STRING</type></property><match-mode>EXACTLY_MATCHES</match-mode><value>" + SearchTextBox.Text + "</value></property-search-restriction>";
                        getResponse retrive     = new getResponse();
                        string      data        = "";
                        retrive.POST(url, XmlDocument, auth, out data);

                        if (data == notFoundXML)

                        {
                            cleanSearchFields();
                            url         = serverURL + "/search?entity-type=user";
                            XmlDocument = "<property-search-restriction><property><name>name</name><type>STRING</type></property><match-mode>EXACTLY_MATCHES</match-mode><value>" + SearchTextBox.Text.Substring(0, SearchTextBox.Text.IndexOf("@")) + "</value></property-search-restriction>";
                            retrive     = new getResponse();
                            data        = "";
                            retrive.POST(url, XmlDocument, auth, out data);
                            if (data == notFoundXML)

                            {
                                cleanSearchFields();
                            }
                        }

                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(data);
                        foreach (XmlNode noda in doc.DocumentElement)
                        {
                            if (noda.LocalName == "user")
                            {
                                UserNameBox.Text = noda.Attributes["name"].Value;
                                userName         = noda.Attributes["name"].Value;

                                foundUsers.Add(userName);
                            }
                        }

                        if (foundUsers.Count > 1)

                        {
                            severalUsersFound();
                        }

                        try
                        {
                            string urlUserSearch = serverURL + "/user?username="******"";
                            retrive.GET(urlUserSearch, auth, out userInfo);

                            doc = new XmlDocument();
                            doc.LoadXml(userInfo);
                            foreach (XmlNode noda in doc.DocumentElement)
                            {
                                if (noda.LocalName == "active")
                                {
                                    active = Convert.ToBoolean(noda.FirstChild.Value);
                                }
                                else if (noda.LocalName == "first-name")
                                {
                                    firstName = noda.FirstChild.Value;
                                }
                                else if (noda.LocalName == "last-name")
                                {
                                    lastName = noda.FirstChild.Value;
                                }
                                else if (noda.LocalName == "email")
                                {
                                    email = noda.FirstChild.Value;
                                }
                            }

                            FirstNameBox.Text = firstName;
                            LastNameBox.Text  = lastName;
                            EmailBox.Text     = email;
                            if (active == true)
                            {
                                ActiveCheckBox.IsChecked = true;
                            }
                            else
                            {
                                ActiveCheckBox.IsChecked = false;
                            }


//Set lable Update on the button if the user was found


                            resetPasswordButton.Visibility = Visibility.Visible;
                            copyGroupButton.Visibility     = Visibility.Visible;

                            CreateUpdateButton.Content = "Update";
                            log("Search - " + SearchTextBox.Text + " - Result: Found username - " + userName);
                            attributsButton.Visibility    = Visibility.Visible;
                            recreateUserButton.Visibility = Visibility.Visible;
                        }

                        catch (Exception ex)
                        {
                            cleanSearchFields();
                        }

//Find a groups for the user

                        getUserGroup();

// Retrive groups list

                        getGroup();
                    }

//If first name and last name provided

                    else if (SearchTextBox.Text.Contains(" "))
                    {
                        string      url     = serverURL + "/search?entity-type=user&restriction=displayName%20=%20%22*" + SearchTextBox.Text + "*%22";
                        getResponse retrive = new getResponse();
                        string      data    = "";
                        retrive.GET(url, auth, out data);

                        if (data == notFoundXML)

                        {
                            cleanSearchFields();
                        }

                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(data);
                        foreach (XmlNode noda in doc.DocumentElement)
                        {
                            if (noda.LocalName == "user")
                            {
                                UserNameBox.Text = noda.Attributes["name"].Value;
                                userName         = noda.Attributes["name"].Value;

                                foundUsers.Add(userName);
                            }
                        }

                        if (foundUsers.Count > 1)

                        {
                            severalUsersFound();
                        }

                        try
                        {
                            string urlUserSearch = serverURL + "/user?username="******"";
                            retrive.GET(urlUserSearch, auth, out userInfo);

                            doc = new XmlDocument();
                            doc.LoadXml(userInfo);
                            foreach (XmlNode noda in doc.DocumentElement)
                            {
                                if (noda.LocalName == "active")
                                {
                                    active = Convert.ToBoolean(noda.FirstChild.Value);
                                }
                                else if (noda.LocalName == "first-name")
                                {
                                    firstName = noda.FirstChild.Value;
                                }
                                else if (noda.LocalName == "last-name")
                                {
                                    lastName = noda.FirstChild.Value;
                                }
                                else if (noda.LocalName == "email")
                                {
                                    email = noda.FirstChild.Value;
                                }
                            }

                            FirstNameBox.Text = firstName;
                            LastNameBox.Text  = lastName;
                            EmailBox.Text     = email;
                            if (active == true)
                            {
                                ActiveCheckBox.IsChecked = true;
                            }
                            else
                            {
                                ActiveCheckBox.IsChecked = false;
                            }

                            //Set lable Update on the button if the user was found
                            resetPasswordButton.Visibility = Visibility.Visible;
                            copyGroupButton.Visibility     = Visibility.Visible;

                            CreateUpdateButton.Content = "Update";
                            log("Search - " + SearchTextBox.Text + " - Result: Found username - " + userName);
                            attributsButton.Visibility    = Visibility.Visible;
                            recreateUserButton.Visibility = Visibility.Visible;
                        }

                        catch (Exception ex)
                        {
                            cleanSearchFields();
                        }

                        //Find a groups for the user

                        getUserGroup();

                        // Retrive groups list

                        getGroup();
                    }


// if search box contains username
                    else
                    {
                        getUserByUserName();
                    }
                }
            }


            if (userName == "")
            {
                listBoxAvailibleGroups.Items.Clear();
                MessageBox1("User not found!");
                if (SearchTextBox.Text.Contains("@"))
                {
                    EmailBox.Text    = SearchTextBox.Text;
                    UserNameBox.Text = SearchTextBox.Text.Substring(0, SearchTextBox.Text.IndexOf("@"));
                    string compOfAcc = SearchTextBox.Text.Substring(SearchTextBox.Text.IndexOf("@") + 1, SearchTextBox.Text.LastIndexOf(".") - SearchTextBox.Text.IndexOf("@") - 1);
                    LastNameBox.Text = " (" + char.ToUpper(compOfAcc[0]) + compOfAcc.Substring(1) + ")";
                    //LastNameBox.Text = SearchTextBox.Text.LastIndexOf(".").ToString();
                }
                log("Search - " + SearchTextBox.Text + " - Result: Not Found");
            }
        }
Example #8
0
        public void getUserByUserName()

        {
            string      url         = serverURL + "/search?entity-type=user";
            string      XmlDocument = "<property-search-restriction><property><name>name</name><type>STRING</type></property><match-mode>EXACTLY_MATCHES</match-mode><value>" + SearchTextBox.Text + "</value></property-search-restriction>";
            getResponse retrive     = new getResponse();
            string      data        = "";

            retrive.POST(url, XmlDocument, auth, out data);
            if (data == notFoundXML)

            {
                cleanSearchFields();
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(data);
            foreach (XmlNode noda in doc.DocumentElement)
            {
                if (noda.LocalName == "user")
                {
                    UserNameBox.Text = noda.Attributes["name"].Value;
                    userName         = noda.Attributes["name"].Value;
                }
            }


            try
            {
                string urlUserSearch = serverURL + "/user?username="******"";
                retrive.GET(urlUserSearch, auth, out userInfo);
                doc = new XmlDocument();
                doc.LoadXml(userInfo);
                foreach (XmlNode noda in doc.DocumentElement)
                {
                    if (noda.LocalName == "active")
                    {
                        active = Convert.ToBoolean(noda.FirstChild.Value);
                    }
                    else if (noda.LocalName == "first-name")
                    {
                        firstName = noda.FirstChild.Value;
                    }
                    else if (noda.LocalName == "last-name")
                    {
                        lastName = noda.FirstChild.Value;
                    }
                    else if (noda.LocalName == "email")
                    {
                        email = noda.FirstChild.Value;
                    }
                }

                FirstNameBox.Text = firstName;
                LastNameBox.Text  = lastName;
                EmailBox.Text     = email;
                if (active == true)
                {
                    ActiveCheckBox.IsChecked = true;
                }
                else
                {
                    ActiveCheckBox.IsChecked = false;
                }

//Set lable Update on the button if the user was found



                resetPasswordButton.Visibility = Visibility.Visible;
                copyGroupButton.Visibility     = Visibility.Visible;
                CreateUpdateButton.Content     = "Update";
                log("Search - " + SearchTextBox.Text + " - Result: Found username - " + userName);
                attributsButton.Visibility    = Visibility.Visible;
                recreateUserButton.Visibility = Visibility.Visible;
            }
            catch (Exception ex)
            {
                cleanSearchFields();
            }

            //Find a groups for the user

            getUserGroup();

            // Retrive groups list

            getGroup();
        }
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            userName  = "";
            firstName = "";
            lastName  = "";
            password  = "";
            groups    = "";
            email     = "";


            foreach (DataRowView row in dataGrid.Items)
            {
                if (row.Row["Directory"].ToString() == "")
                {
                    MessageBox1("Please, verify accounts first ");
                    return;
                }
                if (row.Row["Process"].ToString() == "True")
                {
                    try
                    {
//create

                        userName  = row.Row["F4"].ToString();
                        firstName = row.Row["F2"].ToString();
                        lastName  = row.Row["F3"].ToString();
                        email     = row.Row["F1"].ToString();
                        groups    = "";
                        password  = "******" + Convert.ToString(DateTime.Now) + "Epam";
                        Directory = row.Row["Directory"].ToString();
                        getCredentials();



                        string url         = serverURL + "/user";
                        string XmlDocument = "<user name=\"" + userName + "\" expand=\"attributes\"><first-name>" + firstName + "</first-name><last-name>" + lastName + "</last-name><display-name>" + firstName + " " + lastName + "</display-name><email>" + email + "</email><active>true</active><attributes><link rel=\"self\" href=\"/user/attribute?username="******"\"/></attributes><password><link rel=\"edit\" href=\"/user/password?username="******"\"/><value>" + password + "</value></password></user>";


                        getResponse retrive = new getResponse();
                        string      data    = "";
                        retrive.POST(url, XmlDocument, auth, out data);
                        if (data == "")
                        {
                            return;
                        }


                        row.Row["Status"] = "Created. ";
                        //   set group


                        groups = row.Row["F6"].ToString();
                        string[] group = groups.Split(',');
                        for (int i = 0; i < group.Length; i++)
                        {
                            string addToGroupURL = "/user/group/direct?username="******"<group name=\"" + group[i] + "\"/>";
                            retrive     = new getResponse();
                            data        = "";


                            retrive.POST(serverURL + addToGroupURL + userName, XmlDocument, auth, out data);
                        }
                        row.Row["Status"] = row.Row["Status"] + "Group assigned. ";

//send password


                        sendPassword();
                        row.Row["Status"] = "Processed";

                        log("Create (bulk mode) - " + userName + " - Result: successfully created in " + Directory + " directory and added to the " + groups + " group/s. Email notification about the password sent to: " + email);
                    }

                    catch
                    (Exception ex)
                    {
                        MessageBox1(ex.Message);
                    }
                }


                else
                {
                    row.Row["Status"] = "Skipped";
                }
            }
        }
        private void verifyButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (DataRowView row in dataGrid.Items)
            {
                row.Row["Directory"] = "";
                row.Row["Process"]   = true;
            }

            string      domain        = "";
            string      text          = "";
            string      xmlFile       = File.ReadAllText(Environment.CurrentDirectory + "\\application.conf");
            string      DefaultConfig = "";
            XmlDocument doc           = new XmlDocument();

            doc.LoadXml(xmlFile);
            XmlNodeList elements = doc.GetElementsByTagName("template");


//Set Directory according to the email domains

            for (int i = 0; i < elements.Count; i++)
            {
                domain = elements[i].InnerXml;
                if (elements[i].InnerXml == "default")
                {
                    DefaultConfig = elements[i].ParentNode.Attributes["name"].Value;
                }
                foreach (DataRowView row in dataGrid.Items)
                {
                    text = row.Row.ItemArray[0].ToString();
                    Regex regex = new Regex(domain);
                    Match match = regex.Match(text);
                    if (match.Success)
                    {
                        row.Row["Directory"] = elements[i].ParentNode.Attributes["name"].Value;
                    }
                }
            }

//Set default Directory for unknown email domains

            foreach (DataRowView row in dataGrid.Items)
            {
                if (row.Row["Directory"].ToString() == "")
                {
                    row.Row["Directory"] = DefaultConfig;
                }
            }

//Verify users and emails

            foreach (DataRowView row in dataGrid.Items)
            {
                userName  = row.Row["F4"].ToString();
                email     = row.Row["F1"].ToString();
                Directory = row.Row["Directory"].ToString();
                string Status = "";
                getCredentials();


                string      notFoundXML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><users expand=\"user\"/>";
                string      url         = serverURL + "/search?entity-type=user";
                string      XmlDocument = "<property-search-restriction><property><name>name</name><type>STRING</type></property><match-mode>EXACTLY_MATCHES</match-mode><value>" + userName + "</value></property-search-restriction>";
                getResponse retrive     = new getResponse();
                string      data        = "";
                retrive.POST(url, XmlDocument, auth, out data);

                if (data != notFoundXML)
                {
                    row.Row["Process"] = false;
                    Status             = "UserName already exists. ";
                    row.Row["Status"]  = Status;
                }
                notFoundXML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><users expand=\"user\"/>";
                url         = serverURL + "/search?entity-type=user";
                XmlDocument = "<property-search-restriction><property><name>email</name><type>STRING</type></property><match-mode>EXACTLY_MATCHES</match-mode><value>" + email + "</value></property-search-restriction>";
                retrive     = new getResponse();
                data        = "";
                retrive.POST(url, XmlDocument, auth, out data);

                if (data != notFoundXML)

                {
                    row.Row["Process"] = false;
                    row.Row["Status"]  = Status + "Email already exists.";
                }

                if (row.Row["Status"].ToString() == "")
                {
                    row.Row["Status"] = "Ready";
                }
            }
        }