Purpose: This document shows how to retrieve user information from the security database for display or reporting purposes.
Accessing Information for Users other than the CurrentUser
There are times when it is necessary to retrieve information for a user that is different than the current user. For instance, the primary key of the user that performed an inventory operation is recorded within the database. When a report is created detailing the inventory operation, the user’s username or full name might be retrieved so that it can be added to the report.
The MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO business object contains static (shared) methods that allow user information to be retrieved:
| Method | Description |
|---|---|
| RetrieveUserName() | Accepts a user primary key and returns the user name (login name) for the user. |
| RetrieveFullName() | Accepts a user primary key and a Boolean value indicating whether the last name should be displayed first and returns the full name for the user. |
Accessing Additional Information
Additional information beyond the user’s login name and the full name of the user is stored within the us_Data field in the database. This field is encrypted and the pieces of data stored within the field can only be accessed by accessing them through the strong-typed properties on the SFSUsersBO business object. Therefore, to access additional information, you must create a new instance of the SFSUsersBO business object, populate it with the appropriate user record(s), and access the data through that business object.
Imports MicroFour.StrataFrame.Security
Imports MicroFour.StrataFrame.Security.BusinessObjects
...
Private Sub ShowUserData(ByVal UserPK As Integer)
'-- Create the user business object
Dim user As New SFSUsersBO()
'-- Get the user
user.FillByPrimaryKey(UserPK)
'-- Display the user's password and expiration
MsgBox("Password: " & user.us_PasswordPlainText & ControlChars.CrLf & _
"Never Expires: " & user.us_PasswordNeverExpires.ToString())
'-- Dispose of the bo
user.Dispose()
End Subusing MicroFour.StrataFrame.Security;
using MicroFour.StrataFrame.Security.BusinessObjects;
...
private void ShowUserData(int UserPK)
{
//-- Create the user business object
SFSUsersBO user = new SFSUsersBO();
//-- Get the user
user.FillByPrimaryKey(UserPK);
//-- Display the user's password and expiration
MessageBox.Show("Password" + user.us_PasswordPlainText + "\n" +
"Never Expires: " + user.us_PasswordNeverExpires.ToString());
//-- Dispose of the bo
user.Dispose();
}