Skip to content

Commit 41b60eb

Browse files
committed
Restrict swapping the scope to when we have an operationsError and scope is None (didn't try with scope=baseObject)
1 parent a9e1827 commit 41b60eb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,17 +639,17 @@ def search(self, searchFilter, attributes, sizeLimit=0, baseDN=None) -> list:
639639
searchControls=paged_search_control,
640640
)
641641
except ldap_impacket.LDAPSearchError as e:
642-
if e.getErrorString().find("sizeLimitExceeded") >= 0:
642+
if "sizeLimitExceeded" in str(e):
643643
# We should never reach this code as we use paged search now
644644
self.logger.fail("sizeLimitExceeded exception caught, giving up and processing the data received")
645645
e.getAnswers()
646-
else:
646+
elif "operationsError" in str(e) and self.scope is None:
647647
# if empty username and password is possible that we need to change the scope, we try with a baseObject before returning a fail
648648
if self.username == "" and self.password == "":
649649
self.scope = ldapasn1_impacket.Scope("baseObject")
650650
return self.search(searchFilter, attributes, sizeLimit, baseDN)
651-
else:
652-
self.logger.fail(e)
651+
else:
652+
self.logger.fail(e)
653653
return []
654654
return []
655655

0 commit comments

Comments
 (0)