/// <summary>
        /// Returns all of the users in PaperCut, 
        /// as well as their departmental information.
        /// </summary>
        ///
        /// <returns>
        /// An array of PpcUser that contains all the users
        ///  in PaperCut and their department information.
        /// </returns>
        internal static PpcUser[] GetUsersDepartmentInfo(ServerCommandProxy serverProxy)
        {
            string[] allUsers = GetUserAccounts(serverProxy);
            PpcUser[] allUsersWithDeptInfo = new PpcUser[allUsers.Length];
            string[] propertiesToFetch = { "department", "office" };
            string[] retrievedProperties = new string[2];

            Console.WriteLine("Retrieving department information \nfor {0} PaperCut users...", allUsers.Length);
            Console.WriteLine("########################################\r\n");
            for (int i = 0; i < allUsersWithDeptInfo.Length; i++)
            {
                try
                {
                    allUsersWithDeptInfo[i] = new PpcUser();
                    allUsersWithDeptInfo[i].Username = allUsers[i];
                    retrievedProperties = serverProxy.GetUserProperties(allUsersWithDeptInfo[i].Username, propertiesToFetch);

                    allUsersWithDeptInfo[i].Department = retrievedProperties[0];
                    allUsersWithDeptInfo[i].Department = retrievedProperties[1];

                    if (i != 0 && i % 100 == 0)
                    {
                        Console.WriteLine("Retrieved {0} users so far...", i);
                    }

                    if (i == allUsersWithDeptInfo.Length - 1)
                    {
                        Console.WriteLine("\nRetrieved {0} users.", allUsersWithDeptInfo.Length);
                        Console.WriteLine("########################################\r\n");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }

            return allUsersWithDeptInfo;
        }
        /// <summary>
        /// Retrieves the department information for users from Active Directory.
        /// </summary>
        ///
        /// <returns>
        /// A list of LdapUsers containing the usernames, full names,
        /// department names or department numbers.
        /// </returns>
        public LdapUser[] retrieveUserDepartment(PpcUser[] ppcUsers, string department)
        {
            LdapUser[] ldapUsers = new LdapUser[ppcUsers.Length];

            DirectoryEntry ldapConnection = createDirectoryEntry();
            DirectorySearcher ldapSearch = new DirectorySearcher(ldapConnection);
            string[] requiredProperties = new string[] { "cn", department};

            foreach (String property in requiredProperties)
            {
                ldapSearch.PropertiesToLoad.Add(property);
            }

            for (int i = 0; i < ldapUsers.Length; i++)
            {
                ldapUsers[i] = new LdapUser();
                ldapUsers[i].Username = ppcUsers[i].Username;
                try
                {
                    ldapSearch.Filter = "(sAMAccountName=" + ldapUsers[i].Username + ")";
                    SearchResult result = ldapSearch.FindOne();

                    if (result != null)
                    {
                        try
                        {
                            ldapUsers[i].FullName = result.Properties[requiredProperties[0]][0].ToString();
                            ldapUsers[i].DepartmentName = result.Properties[requiredProperties[1]][0].ToString();
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Incomplete AD information for user: {0}", ldapUsers[i].Username);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Nothing retrieved.");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }

            return ldapUsers;
        }