public ListUsersResponse ListUsers(ListUsersRequest request)
		{
			var criteria = new UserSearchCriteria();
			criteria.UserName.SortAsc(0);
			criteria.AccountType.EqualTo(UserAccountType.U); // only regular user accounts are visible through this service

			// create the criteria, depending on whether matches should be "exact" or "like"
			if (request.ExactMatchOnly)
			{
				if (!string.IsNullOrEmpty(request.UserName))
					criteria.UserName.EqualTo(request.UserName);
				if (!string.IsNullOrEmpty(request.DisplayName))
					criteria.DisplayName.EqualTo(request.DisplayName);
			}
			else
			{
				if (!string.IsNullOrEmpty(request.UserName))
					criteria.UserName.StartsWith(request.UserName);
				if (!string.IsNullOrEmpty(request.DisplayName))
					criteria.DisplayName.Like(string.Format("%{0}%", request.DisplayName));
			}

			var assembler = new UserAssembler();
			var broker = PersistenceContext.GetBroker<IUserBroker>();
			var userSummaries = CollectionUtils.Map(
				broker.Find(criteria, request.Page),
				(User user) => assembler.GetUserSummaryMinimal(user));
			var total = broker.Count(criteria);

			return new ListUsersResponse(userSummaries, (int)total);
		}
		public ListUsersResponse ListUsers(ListUsersRequest request)
		{
			var criteria = new UserSearchCriteria();
			criteria.UserName.SortAsc(0);

			// create the criteria, depending on whether matches should be "exact" or "like"
			if (request.ExactMatchOnly)
			{
				if (!string.IsNullOrEmpty(request.UserName))
					criteria.UserName.EqualTo(request.UserName);
				if (!string.IsNullOrEmpty(request.DisplayName))
					criteria.DisplayName.EqualTo(request.DisplayName);
			}
			else
			{
				if (!string.IsNullOrEmpty(request.UserName))
					criteria.UserName.StartsWith(request.UserName);
				if (!string.IsNullOrEmpty(request.DisplayName))
					criteria.DisplayName.Like(string.Format("%{0}%", request.DisplayName));
			}

			var assembler = new UserAssembler();
			var userSummaries = CollectionUtils.Map(
				PersistenceContext.GetBroker<IUserBroker>().Find(criteria, request.Page),
				(User user) => assembler.GetUserSummary(user));

			return new ListUsersResponse(userSummaries);
		}
Exemple #3
0
        private IList<UserRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            if (maximumRows == 0)
            {
                resultCount = 0;
                return new List<UserRowData>();
            }

            List<UserRowData> users;
            using (var service = new UserManagement())
            {
                var filter = new ListUsersRequest
                                 {
                                     UserName = UserName.Replace("*", "%").Replace("?", "_"),
                                     DisplayName = DisplayName.Replace("*", "%").Replace("?", "_"),
                                     Page = {FirstRow = startRowIndex},
                                     ExactMatchOnly = false
                                 };

                users = CollectionUtils.Map(
                    service.FindUsers(filter),
                    (UserSummary summary) => new UserRowData(summary, service.GetUserDetail(summary.UserName)));
            }
            resultCount = users.Count;

            return users;
        }
Exemple #4
0
		private static IList<UserLookupData> ListUsers(string query)
		{
			var users = new List<UserLookupData>();
			Platform.GetService<IUserAdminService>(
				service =>
				{
					var request = new ListUsersRequest {UserName = query};
					var response = service.ListUsers(request);
					users = CollectionUtils.Map(response.Users, (UserSummary summary) => new UserLookupData(summary.UserName));
				});

			return users;
		}
		public ListUsersResponse ListUsers(ListUsersRequest request)
		{
			// establish which account types this user is entitled to see
			var visibleAccountTypes = GetAccountTypesAuthorizedToManage(request.IncludeGroupAccounts, request.IncludeSystemAccounts).ToList();
			if (!visibleAccountTypes.Any())
				throw new SecurityException(SR.MessageUserNotAuthorized);

			var criteria = new UserSearchCriteria();
			criteria.AccountType.In(visibleAccountTypes);
			criteria.UserName.SortAsc(0);

			// create the criteria, depending on whether matches should be "exact" or "like"
			if (request.ExactMatchOnly)
			{
				if (!string.IsNullOrEmpty(request.UserName))
					criteria.UserName.EqualTo(request.UserName);
				if (!string.IsNullOrEmpty(request.DisplayName))
					criteria.DisplayName.EqualTo(request.DisplayName);
			}
			else
			{
				if (!string.IsNullOrEmpty(request.UserName))
					criteria.UserName.StartsWith(request.UserName);
				if (!string.IsNullOrEmpty(request.DisplayName))
					criteria.DisplayName.Like(string.Format("%{0}%", request.DisplayName));
			}

			var broker = PersistenceContext.GetBroker<IUserBroker>();
			var assembler = new UserAssembler();
			var userSummaries = CollectionUtils.Map(
				broker.Find(criteria, request.Page),
				(User user) => assembler.GetUserSummary(user));
			var total = broker.Count(criteria);

			return new ListUsersResponse(userSummaries, (int)total);
		}
        public IList<UserSummary> FindUsers(ListUsersRequest filter)
        {
            List<UserSummary> users = _service.ListUsers(filter).Users;

            return users;
        }
        public bool ExistsUsername(string username)
        {
            bool exists = false;

            using(UserManagement service = new UserManagement())
            {
                ListUsersRequest filter = new ListUsersRequest();
                filter.ExactMatchOnly = true;
                filter.UserName = username;

                IList<UserSummary> users = service.FindUsers(filter);

                if (users != null && users.Count > 0)
                {
                    exists = true;
                }
            }

            return exists;
        }