Exemplo n.º 1
0
        public static async Task <bool> CheckUser(string user, string masterPassword)
        {
            using (var ocCommand = new OCGetUsers(user))
            {
                ocCommand.setCredentials("admin", masterPassword);
                await ocCommand.sendRequest();

                return(ocCommand.userList.Count == 1);
            }
        }
Exemplo n.º 2
0
        public static async Task <bool> CheckUser(string user)
        {
            using (var ocCommand = new OCGetUsers(user))
            {
                try
                {
                    ocCommand.setCredentials(Credentials);
                    await ocCommand.sendRequest();

                    return(ocCommand.userList.Count >= 1);
                } catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 3
0
        public static async Task <bool> UppUser(string user, string password, string fullName, string groups, string masterPassword)
        {
            using (var ocCommand = new OCGetUsers(user))
            {
                ocCommand.setCredentials("admin", masterPassword);
                await ocCommand.sendRequest();

                if (!ocCommand.userList.Contains(user))
                {
                    return(false);
                }
            }
            using (var ocCommand = new OCEditUser(user, "display", fullName))
            {
                ocCommand.setCredentials("admin", masterPassword);
                await ocCommand.sendRequest();

                if (ocCommand.status != "ok")
                {
                    return(false);
                }
            }
            using (var ocCommand = new OCEditUser(user, "password", password))
            {
                ocCommand.setCredentials("admin", masterPassword);
                await ocCommand.sendRequest();

                if (ocCommand.status != "ok")
                {
                    return(false);
                }
            }
            foreach (var group in groups.Split('|'))
            {
                if (group.Trim() != "")
                {
                    bool result = await CheckGroup(group, masterPassword); //lets check the group exists

                    if (!result)
                    {
                        result = await AddGroup(group, masterPassword); //if it doesnt we create it

                        if (!result)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        result = await CheckUserGroup(user, group, masterPassword); //lets check if the user already belongs to the group

                        if (result)
                        {
                            break;
                        }
                    }
                    result = await AddUserToGroup(user, group, masterPassword);// if he doesnt, we add to the group

                    if (!result)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }