title: How to do a simple search usingLDAP3 without user and passoword?
body: <p>I am trying to write a small app for Linux (Debian Stretch) that basically does what the shell command <code>ldapsearch -x -H ldaps://master.someserver -b 'ou=Users,dc=foo,dc=bar,dc=nl' &quot;sn=*$1*&quot; uid cn mail</code> does. Thus, connecting to an LDAP server and performing a basic search. With this command I have to add only the server's hostname, the baseDN and the search filter.</p>
  <p>In Python, using the ldap3 module, I wrote the following function:</p>
  <pre><code>def search_ldap(sfilter,term):
      result = ()
      baseDN = &quot;ou=Users,dc=foo,dc=bar,dc=nl&quot;
      attributes = ['uid', 'cn', 'mail']
      searchFilter = sfilter.format(term) 
      server = Server('master.someserver.nl')
      conn = Connection(server, auto_bind=True)
      conn.search(baseDN, searchFilter, attributes=attributes)
     response = conn.response[0]['attributes']
  
      return(result)
  </code></pre>
  <p>It does not use password or username. I understood that this would create an anonymous connection. I also understood that in LDAP v3, you do not need a bind for a search. When executing my code, I do however get:</p>
  <pre><code> File &quot;/home/enricm/.local/lib/python3.5/site-packages/ldap3/core/connection.py&quot;, line 412, in _do_auto_bind
      raise LDAPBindError(error)
  </code></pre>
  <p>I assume that this is because of the <code>auto_bind=True</code>, but if I remove that, I get a different error:</p>
  <pre><code> File &quot;/home/enricm/.local/lib/python3.5/site-packages/ldap3/strategy/base.py&quot;, line 336, in send
      raise LDAPSocketOpenError(self.connection.last_error)
  ldap3.core.exceptions.LDAPSocketOpenError: unable to send message, socket is not open
  </code></pre>
  <p>I do also get the ```confidentialityRequired`` error when I provide a username and a password. In this case the &quot;username&quot; is something like this: <code>uid=myuser,ou=Users,dc=foo,dc=bar,dc=nl</code> and my password is a plain text string (which I don't really want to use.</p>
  <p>Is there actually a way of doing a simple search without having to use a bind? Or what am I missing here?</p>