|
@@ -35,17 +35,17 @@ def main():
|
|
l.protocol_version = ldap.VERSION3
|
|
l.protocol_version = ldap.VERSION3
|
|
except ldap.LDAPError as e:
|
|
except ldap.LDAPError as e:
|
|
print(f"Failed to initialize LDAP connection: {e}")
|
|
print(f"Failed to initialize LDAP connection: {e}")
|
|
- sys.exit(1)
|
|
|
|
|
|
+ sys.exit(f"Failed to initialize LDAP connection: {e}")
|
|
|
|
|
|
try:
|
|
try:
|
|
# Attempt to bind with given credentials
|
|
# Attempt to bind with given credentials
|
|
l.simple_bind_s(binddn, pw)
|
|
l.simple_bind_s(binddn, pw)
|
|
except ldap.INVALID_CREDENTIALS:
|
|
except ldap.INVALID_CREDENTIALS:
|
|
print("Authentication to the LDAP host has failed.")
|
|
print("Authentication to the LDAP host has failed.")
|
|
- sys.exit(1)
|
|
|
|
|
|
+ sys.exit("Authentication to the LDAP host has failed.")
|
|
except ldap.LDAPError as e:
|
|
except ldap.LDAPError as e:
|
|
print(f"LDAP error during bind: {e}")
|
|
print(f"LDAP error during bind: {e}")
|
|
- sys.exit(1)
|
|
|
|
|
|
+ sys.exit(f"LDAP error during bind: {e}")
|
|
|
|
|
|
try:
|
|
try:
|
|
ldap_result_id = l.search(basedn, searchScope, searchFilter, searchAttribute)
|
|
ldap_result_id = l.search(basedn, searchScope, searchFilter, searchAttribute)
|
|
@@ -58,7 +58,6 @@ def main():
|
|
elif result_type == ldap.RES_SEARCH_ENTRY:
|
|
elif result_type == ldap.RES_SEARCH_ENTRY:
|
|
result_set.append(result_data)
|
|
result_set.append(result_data)
|
|
|
|
|
|
- #print('<<<edirectory_monitor:sep(124)>>>')
|
|
|
|
print('<<<edirectory_monitor_agent:sep(124)>>>')
|
|
print('<<<edirectory_monitor_agent:sep(124)>>>')
|
|
for i in range(len(result_set)):
|
|
for i in range(len(result_set)):
|
|
for val in result_set[i]:
|
|
for val in result_set[i]:
|
|
@@ -98,7 +97,7 @@ def main():
|
|
|
|
|
|
except ldap.LDAPError as e:
|
|
except ldap.LDAPError as e:
|
|
print(f"LDAP search failed: {e}")
|
|
print(f"LDAP search failed: {e}")
|
|
-
|
|
|
|
|
|
+ sys.exit(f"LDAP search failed: {e}")
|
|
finally:
|
|
finally:
|
|
l.unbind_s()
|
|
l.unbind_s()
|
|
|
|
|