Users Domain Account Statuses

Users Domain Account Statuses
 1# This example queries the account status for all domain (LDAP) users in the database.
 2
 3# Create a local variable for the output toolbox
 4ot = impact.gui.output_toolbox
 5db = impact.active_database
 6
 7# Clear the output toolbox
 8ot.clear()
 9
10# Retrieve the users from the DB
11users = db.users
12
13# Connect to LDAP Service when querying multiple items to improve performance
14if db.connect_to_ldap_service():
15    ot.add("Successfully connected to LDAP Service")
16
17    for i in range(1, users.count  + 1):
18        user = users.item(i)
19
20        if user.ldap_enabled:
21
22            # Output LDAP account status
23            status = user.ldap_user_account_status
24
25            if status is not None:
26                ot.add("  LDAP Account Status for " + str(user.formatted_name))
27                ot.add("    IsDisabled: " + str(status.is_disabled))
28                ot.add("    IsLockedOut: " + str(status.is_locked_out))
29                ot.add("    AccountHasExpired: " + str(status.account_has_expired))
30                ot.add("    PasswordCannotBeChanged: " + str(status.password_cannot_be_changed))
31                ot.add("    PasswordNeverExpires: " + str(status.password_never_expires))
32                ot.add("    PasswordHasExpired: " + str(status.password_has_expired))
33                ot.add("    PasswordMustBeResetAtLogon: " + str(status.password_must_be_reset_at_logon))
34                ot.add("    DaysUntilPasswordExpires: " + str(status.days_until_password_expires))
35                ot.add("    SecondsUntilPasswordExpires: " + str(status.seconds_until_password_expires))
36
37            else:
38                ot.add("Unable to determine LDAP user account status for " + str(user.formatted_name))
39
40    # Remember to disconnect
41    db.disconnect_from_ldap_service()
42
43else:
44    ot.add("Failed to connect to LDAP service: " + str(db.errors.last.description))