Find users by name¶
Find users by name¶
1# This example finds a user in the active database with a specific name, comparison is case insensitive
2
3# Create a local variable for the output toolbox
4ot = impact.gui.output_toolbox
5
6# Clear the output toolbox
7ot.clear()
8
9# Create a local variable for the active database
10db = impact.active_database
11
12# Create a local variable for the name of the users to find
13user_string1 = "Administrator"
14sst1 = ipStringSearchType.sstExact
15
16user_string2 = "D"
17sst2 = ipStringSearchType.sstBeginsWith
18
19# Find any users
20users = db.users.find_by_name(sst1, user_string1)
21
22# Check if any users were found
23if users:
24
25 # Display a message in the output toolbox
26 ot.add("Found the following users:")
27
28 # Loop through the entire list of users that were found
29 for i in range(0, len(users) - 1 + 1):
30
31 # Display the full name of the user in the output toolbox
32 ot.add("Full name: " + str(users[i].full_name))
33
34else:
35
36 # Display a message in the output toolbox
37 ot.add("Unable to find any users from the string '" + str(user_string1) + "'")
38
39
40 # Find any users
41 users = db.users.find_by_name(sst2, user_string2)
42
43 # Check if any users were found
44 if users:
45
46 # Display a message in the output toolbox
47 ot.add("Found the following users:")
48
49 # Loop through the entire list of users that were found
50 for i in range(0, len(users) - 1 + 1):
51
52 # Display the full name of the user in the output toolbox
53 ot.add("Full name: " + str(users[i].full_name))
54
55else:
56
57 # Display a message in the output toolbox
58 ot.add("Unable to find any users from the string '" + str(user_string2) + "'")
59