Beispiel #1
0
        public void SearchFilterBuilderAll()
        {
            string searchFilterExpected = "(objectClass=*)";
            string searchFilter         = LdapFilterBuilder.GetSearchFilter();

            Assert.AreEqual(searchFilterExpected, searchFilter);
        }
Beispiel #2
0
        public void SearchFilterBuilderOnlyObjectClass()
        {
            string searchFilterExpected = String.Format("(objectClass={0})", ObjectClass);
            string searchFilter         = LdapFilterBuilder.GetSearchFilter(ObjectClass);

            Assert.AreEqual(searchFilterExpected, searchFilter);
        }
Beispiel #3
0
        public LdapState SearchUsers(IList <string> otherReturnedAttributes, string[] searchedUsers, out IList <ILdapUser> searchResult)
        {
            searchResult            = new List <ILdapUser>();
            otherReturnedAttributes = otherReturnedAttributes == null?_baseAttributes.ToList() : _baseAttributes.Union(otherReturnedAttributes).ToList();

            try
            {
                //Foreach all the credential,for everyone do the search and add user results to the out parameter
                searchResult = searchedUsers.Select(
                    users =>
                    (SearchResponse)_ldapConnection.SendRequest(
                        LdapRequestBuilder.GetSearchUserRequest(_configRepository.GetSearchBaseDn(),
                                                                LdapFilterBuilder.GetSearchFilter(_configRepository.GetUserObjectClass(),
                                                                                                  _configRepository.GetMatchFieldName(), users), otherReturnedAttributes)
                        ))
                               .Aggregate(searchResult,
                                          (current, searchReturn) =>
                                          current.Concat(LdapUserUtils.ConvertToLdapUsers(searchReturn)).ToList());
            }
            catch (Exception e)
            {
                _logger.Write(_logger.BuildLogMessage(e.Message, LdapState.LdapSearchUserError));
                return(LdapState.LdapSearchUserError);
            }

            if (searchResult.Count == 0)
            {
                _logger.Write(_logger.BuildLogMessage("Search Operation with NO RESULTS", LdapState.LdapSearchUserError));
                return(LdapState.LdapSearchUserError);
            }
            _logger.Write(_logger.BuildLogMessage("Search Operation Success", LdapState.LdapUserManipulatorSuccess));
            return(LdapState.LdapUserManipulatorSuccess);
        }
Beispiel #4
0
        public void SearchFilterBuilderObjectClassAndFieldName()
        {
            string searchFilterExpected = String.Format("(&(objectClass={0})({1}={2}))", ObjectClass, FieldUsername,
                                                        UserCn);
            string searchFilter = LdapFilterBuilder.GetSearchFilter(ObjectClass, FieldUsername, UserCn);

            Assert.AreEqual(searchFilterExpected, searchFilter);
        }
Beispiel #5
0
 public LdapState SearchAllNodes(IList <string> otherReturnedAttributes, out IList <ILdapUser> searchResult)
 {
     return(BaseLdapSearch(otherReturnedAttributes, out searchResult, LdapFilterBuilder.GetSearchFilter()));
 }
Beispiel #6
0
 public LdapState SearchUsers(IList <string> otherReturnedAttributes, out IList <ILdapUser> searchResult)
 {
     return(BaseLdapSearch(otherReturnedAttributes, out searchResult, LdapFilterBuilder.GetSearchFilter(_configRepository.GetUserObjectClass())));
 }