Handle empty search results w/references #84
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'])]