title: Python-ldap not able to bind successfully
body: <p>I am not having any luck finding answers on this, so here it goes.</p>
  
  <p>When I attemtp to connect to an AD server using python-ldap, it appears to work successfully for some functions, and not for others. My connection:</p>
  
  <pre><code>&gt;&gt;&gt;import sys
  &gt;&gt;&gt;import ldap
  
  &gt;&gt;&gt;l = ldap.initialize("ldap://company.com:389")
  &gt;&gt;&gt;l.set_option(ldap.OPT_PROTOCOL_VERSION, 3)
  &gt;&gt;&gt;l.simple_bind_s("user@company.com","password")
  (97, [], 1, [])
  </code></pre>
  
  <p>Some simple google searching indicated that the 97 meant success, although the level of success is a bit wonky. But, for some reason, I cant find anything on the status code 1. If I run some ldap functions on the connection, some of them work and some do not.</p>
  
  <pre><code>&gt;&gt;&gt;l.whoami_s()
  'u:COMPANY.COM\\user'
  </code></pre>
  
  <p>Seems to return fine, but</p>
  
  <pre><code>&gt;&gt;&gt; base_dn = 'dc=company,dc=com'
  &gt;&gt;&gt; retrieveAttributes = ["uniquemember"]
  &gt;&gt;&gt; searchFilter = "cn=user"
  &gt;&gt;&gt; l.search_s(base_dn, ldap.SCOPE_SUBTREE,searchFilter,retrieveAttributes)
  Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/home/user/.envs/scoring/local/lib/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 "/home/user/.envs/scoring/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 546, in search_ext_s
      return self.result(msgid,all=1,timeout=timeout)[1]
    File "/home/user/.envs/scoring/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 458, in result
      resp_type, resp_data, resp_msgid = self.result2(msgid,all,timeout)
    File "/home/user/.envs/scoring/local/lib/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 "/home/user/.envs/scoring/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 469, in result3
      resp_ctrl_classes=resp_ctrl_classes
    File "/home/user/.envs/scoring/local/lib/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 "/home/user/.envs/scoring/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 99, in _ldap_call
      result = func(*args,**kwargs)
  OPERATIONS_ERROR: {'info': '000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1', 'desc': 'Operations error'}
  </code></pre>
  
  <p>I am stumped to why the whoami would work but the search would not. I am using a domain admin for the user, so it shouldn't have anything to do with permissions to the directory. Can anyone shed some light?</p>