Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty search results w/references #84

Merged
merged 1 commit into from
Jan 27, 2021
Merged

Handle empty search results w/references #84

merged 1 commit into from
Jan 27, 2021

Conversation

fredthomsen
Copy link
Contributor

@fredthomsen fredthomsen commented Jan 23, 2021

If a search result is empty but there are result reference locations
that are returned, then the current code will return invalid information
or throw an AttributeError.

Address issue #70.

The search result would be in the format a dn string and then a dictionary containing the proper information about the user, but when the search is empty you just end up with the search references as shown below, and obviously the second item in each tuple is not a dict:

[(None, ['ldap://ForestDnsZones.mycompany.com/DC=ForestDnsZones,DC=mycompany,DC=com']), (None, ['ldap://DomainDnsZones.mycompany.com/DC=DomainDnsZones,DC=mycompany,DC=com']), (None, ['ldap://mycompany.com/CN=Configuration,DC=mycompany,DC=com'])]

A successful search looks something like this:
[('CN=My Name,OU=Users,OU=Accounts,DC=mycompany,DC=com', {'accountExpires': [b'9223372036854775807'], 'cn': [b'First Last'], 'userPrincipalName': [b'email@mycompany.com'], 'whenChanged': [b'20210119003635.0Z'], 'whenCreated': [b'20201005164610.0Z']}), (None, ['ldap://ForestDnsZones.mycompany.com/DC=ForestDnsZones,DC=mycompany,DC=com']), (None, ['ldap://DomainDnsZones.mycompany.com/DC=DomainDnsZones,DC=mycompany,DC=com']), (None, ['ldap://mycompany.com/CN=Configuration,DC=mycompany,DC=com'])]

If a search result is empty but there are result reference locations
that are returned, then the current code will return invalid information
or throw an AttributeError.

Address issue #70.

The search result would be in the format a dn string and then a dictionary
containing the proper information about the user, but when the search is
empty you just end up with the search references as shown below, and
obviously the second item in each tuple is not a dict:

[(None, ['ldap://ForestDnsZones.mycompany.com/DC=ForestDnsZones,DC=mycompany,DC=com']),
 (None, ['ldap://DomainDnsZones.mycompany.com/DC=DomainDnsZones,DC=mycompany,DC=com']),
 (None, ['ldap://mycompany.com/CN=Configuration,DC=mycompany,DC=com'])]

A successful search looks something like this:
[('CN=My Name,OU=Users,OU=Accounts,DC=mycompany,DC=com',
 {'accountExpires': [b'9223372036854775807'],
  'cn': [b'First Last'],
  'userPrincipalName': [b'email@mycompany.com'],
  'whenChanged': [b'20210119003635.0Z'],
  'whenCreated': [b'20201005164610.0Z']}),
  (None, ['ldap://ForestDnsZones.mycompany.com/DC=ForestDnsZones,DC=mycompany,DC=com']),
  (None, ['ldap://DomainDnsZones.mycompany.com/DC=DomainDnsZones,DC=mycompany,DC=com']),
  (None, ['ldap://mycompany.com/CN=Configuration,DC=mycompany,DC=com'])]

Signed-off-by: Fred Thomsen <me@fredthomsen.net>
@alexferl alexferl merged commit 78f66d8 into alexferl:master Jan 27, 2021
@fredthomsen fredthomsen deleted the handleEmptyResultsWithRefs branch January 27, 2021 22:42
@fredthomsen
Copy link
Contributor Author

Thanks. What is the plan for cutting the next release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants