[python-ldap] dirSync control, no Cookie

William Brown william at blackhats.net.au
Tue Oct 4 19:52:55 EDT 2022



> On 16 Sep 2022, at 03:55, Christopher Paul <chris.paul at rexconsulting.net> wrote:
> 
> Hello Python-LDAP,
> 
> I am trying to use python-ldap to  LDAPSearch w/the MS DirSync control '1.2.840.113556.1.4.841'. 
> My ldap.controls.LDAPControl ends up looking like this:
> 
>>>> dirSync.ctrl1.controlType
> '1.2.840.113556.1.4.841'
>>>> dirSync.ctrl1.criticality
> True
>>>> dirSync.ctrl1.encodedControlValue
> b'0\x08\x02\x01\x00\x02\x01\x00\x04\x00'
> 
> This sets flags: 0, maxBytes: 0, with a null Cookie. 
> I get a result using "result4":
> 	adldapconn.result4(msgid=ldap.RES_ANY, all=1, add_ctrls=1, add_intermediates=1, add_extop=1, timeout=30)
> 
> It seems to work in as much as it was able to submit the control and control value to AD (though null cookie), and AD returns the answer with cookie value.
> 
> The problem is that the result4 contains "None, None" for the 3rd and 4th fields, so I cannot get the cookie.
> 
>>>> res=dirSync.dirSync()
> result is (101, [('CN=Jed Tanner,CN=Users,DC=adlab,DC=rexconsulting,DC=net', {'objectGUID': [b't\xfafq\xa6\xa7\xdcI\x8e\xd7\xfe\xde\xdb\xab\xfaa'], 'description': [b'Most Awesome Test User'], 'instanceType': [b'4']}, [])], 2, [], None, None)
> 
> I tried LDAPObject.extop_result too and get (None, None).
> 
> So with no cookie, I cannot make my next control value, though I do see it in tcpdump/wireshark, so know that AD is sending it back.
> 
> Is this a problem with python-ldap or am I doing something wrong? 
> 

I think the cookie value is a control on the search result done message isn't it? Not the last search entry? 

Anyway, it'd probably be best to see what you have code-wise (heck it could even be a good submission I think content sync is already in python-ldap) 


--
Sincerely,

William



More information about the python-ldap mailing list