how to get the object or type of user once the user logs in?

Discussions

EJB design: how to get the object or type of user once the user logs in?

  1. I am developing a complete j2ee application for students registration. i am storing the students & instructors with name & password using beans. When the user log in, I should be able to identify if the logged in user is an object of instrcutor-bean or student-bean. Then accordngly, I should prints the details of that user.
    I am not able to identify the user object (instructor or student), with the user name.
    Can anyone please help me?

    Thanks,
    Ketaki.
  2. I am developing a complete j2ee application for students registration. i am storing the students & instructors with name & password using beans. When the user log in, I should be able to identify if the logged in user is an object of instrcutor-bean or student-bean. Then accordngly, I should prints the details of that user.I am not able to identify the user object (instructor or student), with the user name.Can anyone please help me?Thanks,Ketaki.

    If you are unable to identify the type of user from the username then you will probably need the user to select on logon wether they are a student or instructor.

    Ian Purton
    Website Uptime and Availability | Permission Email List Management | Smartphone GPS | All Time Top 100 Rock Charts
  3. I think your design is wrong. regardless of their type they both are type of user. Its just their roles are different.
  4. If a user can login as a student or an instructor, you need to let them to select what type the user they are.
    But if a user can login “only and only with one role”, as a student or instructor, you need to set the user “Role” to “Student” or “Instructor”.
  5. It all depends on how a particular user has registered (as a Student or Instructor). So based on the username you can query the DB to find out who actually logged in. If at registration the user doesn't specify what is the role then that becomes a Design issue.
  6. Typically, with multi-role systems, there are few restrictions placed on usernames/userIDs, which then allow the system to identify the user's role. Examples are university systems where the userID has a certain format, and so on.

    Another mechanism is to provide different paths for different user types - say, a web-logon for one type of users, while application clients access via a custom protocol (of course over HTTPS/SSH) and pass on a public/private key.


    Hence, for your application, you need to figure out a mechanism for defining the login-process and/or defining user-IDs
  7. have usertype column in ur Db[ Go to top ]

    Include usertype (Student or Teacher) column in your user table.
  8. Using something like Turbine which has a built in user, group, role, and permissions concept, you'll easily be able to provide such a service. With that said. When the user is created you'll need an extra field to indicate the role.
  9. Create a separate table for user-role mapping (to avoid future problems). After login, take "username" and query this table for 'role' - instructor or student.