예제 #1
0
        public void SearchGroups()
        {
            var adGroupList = adRepository.SearchGroups("DSI");

            Assert.IsNotNull(adGroupList);
            Assert.IsTrue(adGroupList.Any());
        }
예제 #2
0
        public List <ActiveDirectoryGroupDTO> SearchActiveDirectoryGroups(ActiveDirectoryGroupListFilterDTO filter)
        {
            var dto = default(List <ActiveDirectoryGroupDTO>);

            try
            {
                if (filter.GroupIdentities == null || filter.GroupIdentities.Count <= default(int))
                {
                    throw new ServiceException(CommonExceptionType.ParameterException, "GroupIdentities");
                }

                if (string.IsNullOrEmpty(filter.Domain))
                {
                    throw new ServiceException(CommonExceptionType.ParameterException, "Domain");
                }

                var adGroupList = new List <ActiveDirectoryGroup>();
                foreach (var identity in filter.GroupIdentities)
                {
                    //Search and casts from groupBase to domain objet Group
                    adGroupList = _adRepo.SearchGroups(identity, filter.Domain)
                                  .Map <List <BaseActiveDirectoryGroup>, List <ActiveDirectoryGroup> >();
                }

                var validations = new List <ValidationResult>();
                adGroupList.AsParallel().ForAll(agl => { agl.Validate(); validations.AddRange(agl.Validation.Results); });

                if (validations.Any())
                {
                    throw new ServiceException(validations);
                }

                dto = adGroupList.Map <List <ActiveDirectoryGroup>, List <ActiveDirectoryGroupDTO> >();
            }
            catch (Exception ex)
            {
                LogHelper.ExceptionAndThrow(ex);
            }

            return(dto);
        }