-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(ingest): If there is no manager for a LDAP user (example: system account) #5180
Conversation
_m_dn, m_attrs = self.ldap_client.result3(manager_msgid)[1][0] | ||
manager_ldap = guess_person_ldap(m_attrs) | ||
result = self.ldap_client.result3(manager_msgid) | ||
if result[1]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this also result in an out of range error if the list is empty? since we want to access index 1, we could check if result.length > 1:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is a Tuple and here is an example where the existing code is going to fail (directly from my debug):
(101, [], 3, [<ldap.controls.libldap.SimplePagedResultsControl object …>])
But checking the number elements in the tuple as: len(result) > 1 will not work because there are 4 elements at this tuple. I think an actual issue is a second [0], when we try to access the first element (index 0) from the second element of the tuple (index 1). However, it is empty ([]) and this is where the error is happaning. By checking result[1] we will skip such scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh gotcha, yeah that was my misunderstanding on what the actual output of self.ldap_client.result3(manager_msgid)
was. Thanks for clarifying!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chriscollins3456 Sure, glad if this was helpful.
The first element of the results3 tuple could be an empty array [], for example, if it is a system account and it has no managers. Thus, the the current code is failing with "out of range" error. I added a quick check if array is not empty which has fixed this error.
Checklist