etianen/django-python3-ldap

comment: In order to perform this operation a successful bind must be completed on the conne ction

pipikej opened this issue · 10 comments

Hello, I receive an error if I try to run ldap_sync_users.

Here is the log:

`LDAP connect succeeded
LDAP bind failed: LDAPOperationsErrorResult - 1 - operationsError - None - 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580 - search
ResDone - None
Traceback (most recent call last):
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\ldap.py", line 182, in connection
yield Connection(c)
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\management\commands\ldap_sync_users.py", line 24, in handle
for user in connection.iter_users():
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\ldap.py", line 92, in
return filter(None, (
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\extend\standard\PagedSearch.py", line 56, in paged_search_generator
result = connection.search(search_base,
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\core\connection.py", line 853, in search
response = self.post_send_search(self.send('searchRequest', request, controls))
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\strategy\sync.py", line 178, in post_send_search
responses, result = self.get_response(message_id)
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\strategy\base.py", line 403, in get_response
raise LDAPOperationResult(result=result['result'], description=result['description'], dn=result['dn'], message=result['message'], response_type=result['type'])
ldap3.core.exceptions.LDAPOperationsErrorResult: LDAPOperationsErrorResult - 1 - operationsError - None - 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the conne
ction., data 0, v2580 - searchResDone - None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "manage.py", line 22, in
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management_init_.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\h210688\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 75, in inner
return func(*args, **kwds)
File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\management\commands\ldap_sync_users.py", line 26, in handle
self.stdout.write("Synced {user}".format(
File "C:\Users\h210688\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 162, in exit
raise RuntimeError("generator didn't stop after throw()")
RuntimeError: generator didn't stop after throw()
`

It successfully connected to the LDAP, but it could not read the users. I am not sure which settings could be wrong. Any idea?

At a guess, you need to provide the following settings: LDAP_AUTH_CONNECTION_USERNAME LDAP_AUTH_CONNECTION_PASSWORD

On Wed, 17 Mar 2021 at 14:28, pipikej @.***> wrote: Hello, I receive an error if I try to run ldap_sync_users. Here is the log: LDAP connect succeeded LDAP bind failed: LDAPOperationsErrorResult - 1 - operationsError - None - 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580 - search ResDone - None Traceback (most recent call last): File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\ldap.py", line 182, in connection yield Connection(c) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\management\commands\ldap_sync_users.py", line 24, in handle for user in connection.iter_users(): File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\ldap.py", line 92, in return filter(None, ( File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\extend\standard\PagedSearch.py", line 56, in paged_search_generator result = connection.search(search_base, File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\core\connection.py", line 853, in search response = self.post_send_search(self.send('searchRequest', request, controls)) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\strategy\sync.py", line 178, in post_send_search responses, result = self.get_response(message_id) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\ldap3\strategy\base.py", line 403, in get_response raise LDAPOperationResult(result=result['result'], description=result['description'], dn=result['dn'], message=result['message'], response_type=result['type']) ldap3.core.exceptions.LDAPOperationsErrorResult: LDAPOperationsErrorResult - 1 - operationsError - None - 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the conne ction., data 0, v2580 - searchResDone - None During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 22, in main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management_ *init*_.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management_ *init*_.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django\core\management\base.py", line 371, in execute output = self.handle(*args, **options) File "C:\Users\h210688\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 75, in inner return func(*args, **kwds) File "C:\Users\h210688\PycharmProjects\iasap\trunk\venv\lib\site-packages\django_python3_ldap\management\commands\ldap_sync_users.py", line 26, in handle self.stdout.write("Synced {user}".format( File "C:\Users\h210688\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 162, in *exit* raise RuntimeError("generator didn't stop after throw()") RuntimeError: generator didn't stop after throw() It successfully connected to the LDAP, but it could not read the users. I am not sure which settings could be wrong. Any idea? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#201>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEKCEJ2EXFT6D33ZRGV63TEC37TANCNFSM4ZKWIX6Q .

You were correct I had wrong credentials. But now it connects to the server successfully and the it froze on this line of code: for user in connection.iter_users(): from the ldap_sync_users.py file.
It does not fetch any user and if timeout is not set it hangs thare till forever. Any idea what could be wrong?

That traceback - did you get it when you [ctr+c] stopped the frozen process?

Yes I did.

That implies it's waiting forever for a server response that never comes.

I would suggest attempting to connect and list your user accounts using calls to the underlying ldap3 library. This feels like a problem either with your network, or ldap3.

Will try.
Just for the info it hangs on the line 24 in ldap_sync_users.py - for user in connection.iter_users():

The error happened because the LDAP server was too slow and I had to comment out LDAP_AUTH_ACTIVE_DIRECTORY_DOMAIN When it was uncommented the sync_ldap_users command did not work. Now sync_ldap_users is working and it sync all users in the database, but if I try to log in I receive LDAP bind failed: LDAPInvalidCredentialsResult - 49 - invalidCredentials - None - None - bindResponse - None. My guess is that is because LDAP_AUTH_ACTIVE_DIRECTORY_DOMAIN is commented. Is there any way how to get the correct ACTIVE_DIRECTORY_DOMAIN? Or it could be some other settings issue?

To make it work I had to comment out line 167 in ldap.py - c.bind(read_server_info=True). For some reason it always crashed on this during the login. I am not sure why since with ldap_sync_users worked fine. Now the login works. Thank you very much for your support and your work!

I have a similar problem, when i specify my ldap credentials it gives me a keyerror on username model_field