Adding a user¶
Adding a user¶
1# This example creates some new 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# get the first site in the DB
14sites = db.sites
15
16if sites.count > 0:
17 site = sites.item(1)
18
19# get the first user group from the DB
20mastersettings = db.find_master_tool_settings(ipMasterSettingType.mstUserGroup)
21usergroup = mastersettings.item(1)
22
23ot.add("UserGroup: " + str(usergroup.name))
24if not site.isNone():
25 ot.add("Site: " + str(site.full_name))
26
27publish_to_enterprise = False
28
29# IUsers.add() is deprecated and IUsers.add2() should be used instead
30new_cad_user = users.add2("LOGINID1", "full_name", "Password", "email@email.com", ipUserType.utCAD, None, usergroup, publish_to_enterprise)
31
32if not new_cad_user.isNone():
33 ot.add("Successfully created user LOGINID1")
34else:
35 ot.add("Unable to create user LOGINID1")
36
37new_n_server_user = users.add2("LOGINID2", "full_name", "Password", "email@email.com", ipUserType.utNServer, site, usergroup, publish_to_enterprise)
38
39if not new_n_server_user.isNone():
40 ot.add("Successfully created user LOGINID2")
41else:
42 ot.add("Unable to create user LOGINID2")
43
44