Пример #1
0
        private void CompleteUserSearch(SearchRequestState requestState, LdapMessageQueue searchQueue)
        {
            var response = searchQueue.GetResponse();

            if (!(response is LdapSearchResult searchResult))
            {
                _logger.LogTrace($"Received an unexpected result of type '{response?.GetType()}' from LDAP search.");
                requestState.SetNoResult();
                return;
            }

            if (searchResult.Entry == null)
            {
                _logger.LogTrace($"Could not find an LDAP user with the filter '{requestState.Filter}'");
                requestState.SetNoResult();
                return;
            }

            var user = User.FromLdapEntry(searchResult.Entry);

            requestState.SetResult(user);
        }
Пример #2
0
 private void ExecuteSearchSafe(SearchRequestState requestState)
 {
     try
     {
         var searchQueue = StartUserSearch(requestState);
         CompleteUserSearch(requestState, searchQueue);
     }
     catch (Exception e)
     {
         _logger.LogError(e, $"Error searching for an LDAP with the filter '{requestState.Filter}'");
         requestState.SetNoResult();
     }
     finally
     {
         requestState.Dispose();
     }
 }