'how to search with an attribute which is dn using python-ldap?

I have an LDAP entity whose attribute is a dn. For example, assume the entity "cn=machine1,ou=machines,dc=company,dc=com" has an attribute "belongsTo" which is "cn=group1,ou=groups,dc=cisco,dc=com"

How to write search filter to retrieve all machine entries which belongs to group1

I wrote something like below but its not working as it don't know where to break =

search_s('ou=machines,dc=company,dc=com',
         SCOPE_ONELEVEL,
         '(belongsTo=cn=group1,ou=groups,dc=cisco,dc=com")'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source