title: django_auth_ldap - AUTH_LDAP_REQUIRE_GROUP
body: <p>I am using django_auth_ldap. Login without checking for a group works fine.</p>
  
  <p>But trying to login with the user <code>example_user</code> which was added to the group <code>example_group</code> on LDAP and setting <code>AUTH_LDAP_REQUIRE_GROUP</code> fails.</p>
  
  <p><strong>settings.py</strong></p>
  
  <pre><code>AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
  AUTH_LDAP_START_TLS = True
  
  AUTH_LDAP_BIND_DN = ""
  AUTH_LDAP_BIND_PASSWORD = ""
  AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=users,dc=example,dc=com",
      ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
  
  
  
  # Set up the basic group parameters.
  AUTH_LDAP_GROUP_SEARCH = LDAPSearch("cn=example_group,cn=groups,dc=example,dc=com",
      ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)"
  )
  
  AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn")
  
  
  AUTH_LDAP_REQUIRE_GROUP = "cn=example_group,cn=groups,dc=example,dc=com"
  </code></pre>
  
  <p>From the logs:</p>
  
  <pre><code>search_s('cn=users,dc=example,dc=com', 2, '(uid=%(user)s)') returned 1 objects: cn=example_user,cn=users,dc=example,dc=com
  cn=example_user,cn=users,dc=example,dc=com is not a member of cn=example_group,cn=groups,dc=example,dc=com
  Authentication failed for example_user: user does not satisfy AUTH_LDAP_REQUIRE_GROUP
  </code></pre>
  
  <p>$ ldapsearch -x -h ldap.example.com b"cn=example_group,cn=groups,dc=example,dc=com"</p>
  
  <pre><code>ldap_bind: Success (0)
      [...]
  # extended LDIF
  #
  # LDAPv3
  # base &lt;cn=example_group,cn=groups,dc=example,dc=com&gt; with scope subtree
  # filter: (objectclass=*)
  # requesting: ALL
  #
  
  # example_group, Groups, example.com
  dn: cn=example_group,cn=Groups,dc=example,dc=com
  cn: example_group
  objectclass: top
  objectclass: groupOfUniqueNames
  objectclass: orclGroup
  description: [...]
  displayname: example_group
  orclisvisible: true
  uniquemember: cn=example_user,cn=users,dc=example,dc=com
  
  # search result
  search: 2
  result: 0 Success
  
  # numResponses: 2
  # numEntries: 1
  </code></pre>