title: How to query LDAP group membership with curl?
body: <p>I would like to use <code>curl</code> on the command line to check if a <code>$USER</code> is a member of the LDAP group <code>$GROUP</code>. </p>
  
  <p>This works:</p>
  
  <pre><code>curl --user $CREDS \
       "ldaps://ldap.foo.com/DC=ads,DC=foo,DC=com??sub?(sAMAccountName=$USER)" \ 
     | grep -a "memberOf: CN=$GROUP,OU=Distribution,OU=Groups,DC=ads,DC=foo,DC=com"
  </code></pre>
  
  <p>Unfortunately, that call takes quite some time and it returns a lot of info that I am not interested in. Do you know if a more efficient way exists?</p>