@William Brown

Are there any chance we can use these filter with filter module directly .

F1 = "(sn=Hall)"
F2 = "(nsRoleDN=cn=new managed role)"
F3 = "(l=sunnyvale)"
F4 = "(& (| {} {}) {})".format(F2, F1, F3)
F10 = "(& {} {})".format(F6, F9)

topo.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, F4, ['cn', 'cn', 'cn'])
>>[dn: uid=bhall,ou=People,dc=example,dc=com
cn: Benjamin Hall

]

topo.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, F10, ['mailquota', 'nsRoleDN'])
>> [dn: uid=mtyler,ou=People,dc=example,dc=com
mailquota: 600
nsRoleDN: cn=new managed role,ou=People,dc=example,dc=com

]

Regards
Anuj Borah

On Mon, Apr 29, 2019 at 12:29 PM Anuj Borah <aborah@redhat.com> wrote:
Yes, it is.

On Mon, Apr 29, 2019 at 11:17 AM William Brown <wbrown@suse.de> wrote:


> On 29 Apr 2019, at 15:00, Anuj Borah <aborah@redhat.com> wrote:
>
> @William Brown
>
> Sorry my bad , syntax was wrong .
>
> (Pdb) len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(testUserAccountControl:1.2.840.113556.1.4.803:=8388608, ['attrlist=cn:sn:uid:testUserAccountControl'])"))
> 6
>
> Thanks .
>
>
> On Mon, Apr 29, 2019 at 10:26 AM Anuj Borah <aborah@redhat.com> wrote:
> @William Brown
>
> This is the filter :    "testUserAccountControl:1.2.840.113556.1.4.803:=8388608", ['attrlist=cn:sn:uid:testUserAccountControl']
>
> len(topo.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,"testUserAccountControl:1.2.840.113556.1.4.803:=8388608", ['attrlist=cn:sn:uid:testUserAccountControl'])) --- Thid one works .
> > 6
>
> But the full filter does not fit with filter module .
>
> > (Pdb) len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(testUserAccountControl:1.2.840.113556.1.4.803:=8388608)", ['attrlist=cn:sn:uid:testUserAccountControl']))
> > *** TypeError: filter() takes 2 positional arguments but 3 were given
> > (Pdb) len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(testUserAccountControl:1.2.840.113556.1.4.803:=8388608), ['attrlist=cn:sn:uid:testUserAccountControl']"))
> > *** ldap.FILTER_ERROR: {'desc': 'Bad search filter', 'errno': 2, 'info': 'No such file or directory'}
>
>
> Regards
> Anuj Borah
>

That filter string seems really … uhh, interesting. You are testing:

(testUserAccountControl:1.2.840.113556.1.4.803:=8388608, ['attrlist=cn:sn:uid:testUserAccountControl’])

Is that really a valid filter?



Sincerely,

William Brown

Senior Software Engineer, 389 Directory Server
SUSE Labs