-
Notifications
You must be signed in to change notification settings - Fork 2
Adding Users
ClassDB provides three functions to add database users: one for each user role ClassDB defines. The functions are located in the classdb schema and can be executed by Instructors and DBManagers.
Each user-creation function creates a user on the server in which ClassDB is installed and makes the new user a member of the corresponding role. It also creates a $user schema for each user within the database where the function is executed, assigns appropriate privileges for the user on that schema, appropriately registers them in a table ClassDB maintains.
Regardless of the role, every user name must be unique among all users on the server, even among users not created through ClassDB. By default, user names are not case sensitive, but a user name may be enclosed in double quotes to make it case sensitive. See Postgres documentation for details on user names and other PostgreSQL identifiers.
In all cases, an initial password may be optionally supplied. If the initial password is not supplied, it is set to the same value as the user name. Whether an explicit initial password is provided or a default initial password is used, every user should change their password soon after first log in.
Function createInstructor creates an Instructor. This function takes three parameters:
-
instructorUserName- Required - The username the instructor will use to connect to the server instance -
instructorName- Required - The instructor's given name. This name is stored for later reference -
initialPwd- Optional - The initial password for the user
Execute the following query to create an instructor with username "caldwellj", given name "Jessica Caldwell", and the default initial password (their username).
SELECT classdb.createInstructor('caldwellj', 'Jessica Caldwell');
Execute the following query to create the same user as above, but with an initial password of "LV8jzugmfFBF":
SELECT classdb.createInstructor('caldwellj', 'Jessica Caldwell', 'LV8jzugmfFBF');
In both the examples shown above, the user name is not case sensitive. Execute the following query to create the same user as above and make the user name case sensitive. The use of the double quotes makes the user name case sensitive, requiring the user to use the exact string CaldwellJ to log in:
SELECT classdb.createInstructor('"CaldwellJ"', 'Jessica Caldwell', 'LV8jzugmfFBF');
Function createStudent creates a Student. This function takes four parameters:
-
studentUserName- Required - The username the student will use to connect to the server instance -
studentName- Required - The student's given name. This name is stored for later reference -
schoolID- Optional - The school issued ID assigned to the Student. If provided, it is stored for later reference -
initialPwd- Optional - The initial password for the user
Execute the following query to create a student with username "bell001", given name "Emmett Bell", no school-issued ID, and the default initial password (their username).
SELECT classdb.createStudent('bell001', 'Emmett Bell');
Execute the following query to create the same user as above, but with a school-issued ID "B584452" and default initial password:
SELECT classdb.createStudent('bell001', 'Emmett Bell', 'B584452');
Execute the following query to create the same student with an initial password of "w18nwMcK&606":
SELECT classdb.createStudent('bell001', 'Emmett Bell', 'B584452', 'w18nwMcK&606');
Finally, execute the following query to create the same student with the same explicit initial password, but not provide a school-issued ID:
SELECT classdb.createStudent('bell001', 'Emmett Bell', NULL, 'w18nwMcK&606');
A DBManager can be created by calling the createDBManager function. This function takes three parameters, which are all case-sensitive:
-
managerUserName- Required - The username that the user will use to connect to the ClassDB instance -
managerName- Required - The name for the user -
initialPwd- Optional - The initial password for the user. If one is not provided, then the initial password defaults to the user name
To create a DBManager named "Emilio Martin" with a username of martine and with a default initial password (their username), the following query should be executed:
SELECT classdb.createDBManager('martine', 'Emilio Martin');
To create the above user, but with an initial password of 'Cid8&88#M8Y8', then the following would be executed:
SELECT classdb.createDBManager('martine', 'Emilio Martin', 'Cid8&88#M8Y8');
Andrew Figueroa
Data Science & Systems Lab (DASSL), Western Connecticut State University (WCSU)
(C) 2017- DASSL. ALL RIGHTS RESERVED.
Licensed to others under CC 4.0 BY-SA-NC: https://creativecommons.org/licenses/by-nc-sa/4.0/
PROVIDED AS IS. NO WARRANTIES EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.