Add CRUD methods to ldap#2097
Conversation
|
So great :D!! |
|
Nice one 🎉 |
|
@anadrianmanrique i don't want to mess with your priority list too much, but i think it would be nice to have this one merged some time soon so we (in NetExec) can start replacing all manually established ldap3 connections in NetExec with impacket. |
|
hello, @NeffIsBack I'll be reviewing these changes next week. I'll be discussing with the team also this PR, as it duplicates functionality with ldap3, which is intended to be potentially, as you mention, replaced. |
|
Sounds good👍🏼 Besides that ldap3 had some maintenance issues, there are two core issues that arises with the use in NetExec:
TLDR; I don't want to discourage the use of ldap3 which is by all means a good lib, but rather simplify NetExec (and impacket) development by being able to rely on just one ldap implementation instead of having two intertwined in the project. A few PRs and features of NetExec that reestablish the connection using ldap3 just because of the lack of CRUD functions:
|
|
ok, I created ldap_examples_update branch in order to port there examples from ldap3 to impacket.ldap . Thanks! |
|
Awesome! Glad to hear, we'll get things moving in NetExec as well. Keep in mind that the syntax works as before, but ldap3 did not raise exceptions when it received errors, while impacket does. Can happen for example if you try to add an object that already exists. |
|
Dear @fortra team, @gabrielg5, @anadrianmanrique, LDAP Channel Binding support will be added with your recent changes? @dadevel has done a good work here: |
LDAP channel binding is supported by default with impackets LDAP implementation. Once example scripts etc are migrated every script will support channel binding by default. |
Until now for all modification operations ldap3 must be used, due to the lack of CRUD methods in ldap (yeah R=read exists, but w/e).
This is now supported!
The implementation is very close to the syntax of the corresponding ldap3 calls in order to be a drop-in-place. Therefore, all existing calls should be able to be replaced by simply switching to impackets ldap. Keep in mind that ldap3 returns
Falsetogether with populatingconnection.last_error, while impackets implementation raises an error. Therefore, error handling must be adjusted. If there are issues (now or in the future) where impackets ldap does not behave similar to ldap3 please hit me up.Subsequently, all existing ldap3 adaptations inside of impacket and NetExec can gradually be replaced by impackets ldap implementation.

Example of adding, modifying and deleting a computer object from NetExec:
Note that i have not tested the
modify_dn()function because i had no proper use-case (at least that worked). Since it is pretty simple, i don't think i have messed it up.