Hello, I am building a B2 that needs to know some info about the currently logged in user like name, user name and role. How can i establish something like this ???
It does depends on how you are building your tool and for which platform Learn 9.1 or SAAS.
You can either use the standard Java API's available here. Or you can use the public REST API's available here.
Both of these routes, permit you to access User and Role data.
thanks a lot for your response, I really appreciate it. Since my platform is learn I am working with the standard Java API's. Unfortunately I am unable to achieve it, Could you provide me with an example ?? or tell me where I can find one ??
A simple example to get you going.
Add the code below into a view JSP - to see the affect:
//At the very least you need the following Bb API definitions
<%-- Define the Blackboard API's to use --%>
<%@page import=blackboard.data.user.UserInfo %>
<%@page import=blackboard.data.user.User %>
<%@page import=blackboard.persist.Id %>
<%-- Define the standard Bb Tag Libraries - note that bbData is being deprecated in the future for SaaS --%>
<%@ taglib uri="/bbData" prefix="bbData"%>
<%@ taglib uri="/bbNG" prefix="bbNG"%>
User user = ctx.getUser();
String studentId = user.getStudentId();
String firstName = user.getGivenName();
String familyName = user.getFamilyName();
//All other JSP code follows here
The methods getStudentId() and getGivenName() can be found in the JavaDoc's for blackboard.data.user.User and blackboard.data.user.UserInfo the links refer to the Q2 2018 API's. You should consult the JavaDoc documentation for the Bb version that you are using.
Thanks a lot, Barbara, it is really helpful.
Retrieving data ...