quinot / ansible-plugin-lookup_ldap

Ansible LDAP lookup plugin
50 stars 16 forks source link

Showing failed bind #23

Open taschaal opened 6 years ago

taschaal commented 6 years ago

Showing failed bind, but when I look at the packet trace I see a successful bind and search.

LDAP config: {u'url': u'ldap://<< my host >>', u'binddn': u'<< my DN >>', u'bindpw': u'<< my password >>', 'wantlist': True, u'value': u'dn'} Attribute props: {u'dn': None} LDAP search, expanded: {u'binddn': u'<< my DN >>', u'url': u'ldap://<< my host >>', u'value': u'dn', 'filter': u'(cn=mslcsdm02)', 'base': u'dc=regence,dc=com', u'bindpw': u'<< my password >>', 'wantlist': True, 'context': {u'binddn': u'<< my DN >>', u'url': u'ldap://<< my host >>', u'value': u'dn', u'filter': u'(cn=mslcsdm02)', u'base': u'dc=regence,dc=com', u'bindpw': u'<< my password >>', 'context': {u'url': u'ldap://<< my host >>', u'binddn': u'<< my DN >>', u'base': u'dc=regence,dc=com', u'bindpw': u'<< my password >>', u'scope': u'subtree'}, u'scope': u'subtree'}, 'scope': u'subtree'} The full traceback is: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 96, in run items = self._get_loop_items() File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 229, in _get_loop_items items = mylookup.run(terms=loop_terms, variables=self._job_vars, wantlist=True) File "/u/r603849/jenkins-vm-deploy/roles/remove-ad-objects/lookup_plugins/ldap.py", line 214, in run lr = lo.search_s(base, scope, *args) File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 552, in search_s return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout) File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 546, in search_ext_s return self.result(msgid,all=1,timeout=timeout)[1] File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 458, in result resp_type, resp_data, resp_msgid = self.result2(msgid,all,timeout) File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 462, in result2 resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all,timeout) File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 469, in result3 resp_ctrl_classes=resp_ctrl_classes File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 476, in result4 ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop) File "/usr/lib64/python2.7/site-packages/ldap/ldapobject.py", line 99, in _ldap_call result = func(args,**kwargs) OPERATIONS_ERROR: {'info': '000004DC: LdapErr: DSID-0C09075A, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1', 'desc': 'Operations error'}

fatal: [localhost]: FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" } to retry, use: --limit @/u/r603849/jenkins-vm-deploy/testad.retry

taschaal commented 6 years ago

Never mind. digging trough some other threads I found a resolution. Added the following to ldap.py

        lo = ldap.initialize(ctx['url'])
        `lo.set_option(ldap.OPT_REFERRALS,0)`

IMO it seems like disabling referrals should be an argument in the plugin

quinot commented 6 years ago

Thanks for doing the research. Sounds like a reasonable suggestion for a new option indeed.