예제 #1
0
        public void getUserGroup()

        {
            try
            {
                UserGropsListBox.Items.Clear();
                string      urlUserGroupSearch = serverURL + "/user/group/direct?username="******"";
                retrive.GET(urlUserGroupSearch, auth, out groupList);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(groupList);
                foreach (XmlNode noda in doc.DocumentElement)
                {
                    if (noda.LocalName == "group")
                    {
                        UserGropsListBox.Items.Add(noda.Attributes["name"].Value);
                    }
                }
            }


            catch

            (Exception ex)
            {
                MessageBox1(ex.Message);
            }
        }
예제 #2
0
        public void getGroup()

        {
            try
            {
                listBoxAvailibleGroups.Items.Clear();
                string      urlGroupSearch = serverURL + "/search?entity-type=group";
                getResponse retrive        = new getResponse();
                string      groupList      = "";
                retrive.GET(urlGroupSearch, auth, out groupList);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(groupList);
                foreach (XmlNode noda in doc.DocumentElement)
                {
                    if (noda.LocalName == "group")
                    {
                        listBoxAvailibleGroups.Items.Add(noda.Attributes["name"].Value);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox1(ex.Message);
            }
        }
예제 #3
0
        public void GroupsTab()
        {
            try
            {
                existingGroupsComboBox.Items.Clear();
                string      urlGroupSearch = serverURL + "/search?entity-type=group";
                getResponse retrive        = new getResponse();
                string      groupList      = "";
                retrive.GET(urlGroupSearch, auth, out groupList);


                XmlDocument doc = new XmlDocument();
                doc.LoadXml(groupList);
                foreach (XmlNode noda in doc.DocumentElement)
                {
                    if (noda.LocalName == "group")
                    {
                        existingGroupsComboBox.Items.Add(noda.Attributes["name"].Value);
                    }
                }

                existingGroupsComboBox.SelectedIndex = 0;
            }

            catch (Exception ex)
            {
                MessageBox1(ex.Message);
            }
        }
예제 #4
0
        private void deleteUserFromGroup_Click(object sender, RoutedEventArgs e)
        {
            string groupListToDelete = "";

            foreach (var group in UserGropsListBox.SelectedItems)
            {
                groupListToDelete += " '" + group.ToString() + "' ";
            }

            DialogBox DialogBox1 = new DialogBox();

            DialogBox1.Show("User '" + UserNameBox.Text + "' will be removed from the groups:" + groupListToDelete + ". Would you like to continue?");

            if (DialogBox1.DialogResult == true)
            {
                foreach (var group in UserGropsListBox.SelectedItems)
                {
                    getCredentials();
                    string      removeFromTheGroupURL = "/user/group/direct?username="******"&groupname=" + group.ToString();
                    getResponse retrive = new getResponse();
                    string      data    = "";
                    retrive.DELETE(serverURL + removeFromTheGroupURL, auth, out data);
                }
                getUserGroup();
                log("Remove User From Group - " + UserNameBox.Text + ". Result: user removed from the groups:" + groupListToDelete);
            }
        }
예제 #5
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");
        }
예제 #6
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);
            }
        }
예제 #8
0
        //private void logo_Click(object sender, RoutedEventArgs e)

        //{
        //    System.Diagnostics.Process proc = new System.Diagnostics.Process();
        //    proc.StartInfo.FileName = "mailto:[email protected]?subject=ServiceRequest // "+DateTime.UtcNow.ToUniversalTime();
        //    proc.Start();
        //}

        private void attributsButton_Click(object sender, RoutedEventArgs e)
        {
            string      attributes        = "";
            string      urlUserAttributes = serverURL + "/user/attribute?username="******"";

            retrive.GET(urlUserAttributes, auth, out attributesList);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(attributesList);
            foreach (XmlNode noda in doc.DocumentElement)
            {
                if (noda.LocalName == "attribute")
                {
                    var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                    switch (noda.Attributes["name"].Value)
                    {
                    case "requiresPasswordChange": attributes += "Requires Password Change : " + noda.InnerText + "\r\n";
                        break;

                    case "invalidPasswordAttempts": attributes += "Invalid Password Attempts : " + noda.InnerText + "\r\n";
                        break;

                    case "autoGroupsAdded": attributes += "Auto Groups Added : " + noda.InnerText + "\r\n";
                        break;

                    case "lastActive": attributes += "Last Active : " + epoch.AddMilliseconds(Convert.ToInt64(noda.InnerText)).ToString() + "\r\n";
                        break;

                    case "lastAuthenticated": attributes += "Last Authenticated : " + epoch.AddMilliseconds(Convert.ToInt64(noda.InnerText)).ToString() + "\r\n";
                        break;

                    case "passwordLastChanged": attributes += "Password Last Changed : " + epoch.AddMilliseconds(Convert.ToInt64(noda.InnerText)).ToString() + "\r\n";
                        break;

                    default: continue;
                    }
                }
            }

            MessageBox1(attributes);
        }
예제 #9
0
        public void getUserGroups(string user)

        {
            foreach (var directory in directories)
            {
                if (listBoxSearchUser.Items.Count != 0)
                {
                    return;
                }

                getCredentials(directory);

                try
                {
                    listBoxSearchUser.Items.Clear();
                    string      urlUserGroupSearch = serverURL + "/user/group/direct?username="******"";
                    retrive.GET(urlUserGroupSearch, auth, out groupList);

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(groupList);
                    foreach (XmlNode noda in doc.DocumentElement)
                    {
                        if (noda.LocalName == "group")
                        {
                            listBoxSearchUser.Items.Add(noda.Attributes["name"].Value);
                        }
                    }
                }


                catch

                (Exception ex)
                {
                    MessageBox1(ex.Message);
                }
            }
        }
예제 #10
0
        private void deleteGroupButton_Click(object sender, RoutedEventArgs e)
        {
            if (existingGroupsComboBox.Text == "")
            {
                MessageBox1("Please, select group to delete first");
                return;
            }
            DialogBox DialogBox1 = new DialogBox();

            DialogBox1.Show("Group " + existingGroupsComboBox.Text + " will be deleted from the system. Would you like to continue?");
            if (DialogBox1.DialogResult == true)
            {
                getCredentials();
                string      urlGroupSearch = serverURL + "/group?groupname=" + existingGroupsComboBox.Text;
                getResponse retrive        = new getResponse();
                string      groupList      = "";
                retrive.DELETE(urlGroupSearch, auth, out groupList);
                MessageBox1(existingGroupsComboBox.Text + " group successfully deleted");
                GroupsTab();
                log("Delete Group - " + existingGroupsComboBox.Text + ". Result: group successfully deleted");
            }
        }
예제 #11
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();
     }
 }
예제 #12
0
        private void GetMambersButton_Click(object sender, RoutedEventArgs e)
        {
            listBox.Items.Clear();
            totalMembersCountTextBlock.Text = "";
            if (existingGroupsComboBox.Text == "")
            {
                MessageBox1("Please, select group first.");


                return;
            }
            try
            {
                string      urlGroupMembersSearch = serverURL + "/group/user/direct?groupname=" + existingGroupsComboBox.Text + "&max-result=10000";
                getResponse retrive          = new getResponse();
                string      groupMembersList = "";
                retrive.GET(urlGroupMembersSearch, auth, out groupMembersList);
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(groupMembersList);
                foreach (XmlNode noda in doc.DocumentElement)
                {
                    if (noda.LocalName == "user")
                    {
                        listBox.Items.Add(noda.Attributes["name"].Value);
                    }
                }

                totalMembersCountTextBlock.Text = "Total: " + listBox.Items.Count;
                log("Get Group Members - " + existingGroupsComboBox.Text + ". Result: " + totalMembersCountTextBlock.Text + ": users found");
            }

            catch (Exception ex)
            {
                MessageBox1(ex.Message);
            }
        }
예제 #13
0
        private void DeleteUserButton_Click(object sender, RoutedEventArgs e)
        {
            if (UserNameBox.Text == "")
            {
                MessageBox1("'User Name' field is empty");
                return;
            }

            DialogBox DialogBox1 = new DialogBox();

            DialogBox1.Show("User '" + UserNameBox.Text + "' will be deleted from the system. Would you like to continue?");

            if (DialogBox1.DialogResult == true)
            {
                getCredentials();

                string      removeUserURL = "/user?username="******"";
                retrive.DELETE(serverURL + removeUserURL, auth, out data);
                MessageBox1("User '" + UserNameBox.Text + "' was successfully removed from the system");
                log("Delete User - " + UserNameBox.Text + " - Result: successfully removed from the system");
            }
        }
예제 #14
0
        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";
                }
            }
        }
        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);
                }
            }
        }
예제 #16
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();
        }
예제 #17
0
        private void searchButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (var directory in directories)
            {
                getCredentials(directory);

                searchTextBox.Text = searchTextBox.Text.TrimStart(' ').TrimEnd(' ');

                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);

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

                            foundUsers.Add(userName);
                        }
                    }
                }

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

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

                            foundUsers.Add(userName);
                        }
                    }

                    searchTextBox.Text.Substring(0, searchTextBox.Text.IndexOf("@"));

                    url     = serverURL + "/search?entity-type=user&restriction=name%20=%20%22*" + searchTextBox.Text + "*%22";
                    retrive = new getResponse();
                    data    = "";
                    retrive.GET(url, auth, out data);

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

                            foundUsers.Add(userName);
                        }
                    }
                }

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

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

                            foundUsers.Add(userName);
                        }
                    }
                }
            }
            if (foundUsers.Count == 0)
            {
                MessageBox1("No users found");
                return;
            }

            getUserGroups(foundUsers.Last());
        }
예제 #18
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");
            }
        }
예제 #19
0
        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";
                }
            }
        }
예제 #20
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);
                    }
                }
            }
        }