ldap3 icon indicating copy to clipboard operation
ldap3 copied to clipboard

Add a way to send an empty AttributeSelection in SearchRequest to request all attributes

Open TomiBelan opened this issue 1 year ago • 0 comments

  • If you call search(..., attributes=None) or search(..., attributes=[]), ldap3 sends attributes=AttributeSelection: 1.1
  • If you call search(..., attributes=ALL_ATTRIBUTES), ldap3 sends attributes=AttributeSelection: *
  • If you call search(..., attributes=ALL_OPERATIONAL_ATTRIBUTES), ldap3 sends attributes=AttributeSelection: +

I'm trying to use ldap3 with a tiny ldap server (https://github.com/dbaarda/LightLdapd) which does not understand * or +. But it gives all attributes when the AttributeSelection is empty. (implementation)

RFC 4511 #4.5.1.8 also suggests this is a valid thing you can do:

  1. An empty list with no attributes requests the return of all user attributes.

There should be a way to force ldap3 to really send an empty list, and not insert "1.1".

I'm using this dirty hack as a workaround: search(..., attributes=(x for x in [])). This works because ldap3 allows GeneratorType in SEQUENCE_TYPES and it doesn't realize in if attributes: that it's empty.

I know nothing about LDAP so I hope I didn't misunderstand anything. I don't know if this particular server is strictly speaking RFC compliant or not, but I'd still like ldap3 to have this ability.

TomiBelan avatar Dec 01 '23 19:12 TomiBelan