Hi ,
I'm trying to get all the database user's last active sessions informations from the Aris Administration.
There is a field called "Active Sessions", but it is only reporting users that are logged into the database if I'm correct.
There is another field called "History", and this one is empty.
Does someone know how I can retrieve, by using report scripting, the last active session (date and time) for all the users assigned to a specific database ?
Hey Willem,
Thanks for your answer.
Unfortunately I can't download the file you uploaded. Could you transfer it via email please at : jordantangy@hotmail.fr
If it's only about the number of user logins you could use the exportable statistics of User management available via /#default/adminUsers and there on Additional functions/Export user statistics.
You choose a start and end date and as event type Login successful to get a CSV file with the timestamps and the user names, such as:
time;"eventType";"node";"executorLogin";"executorIp";"expiry";"sessionId";"sessionType" | ||||||||||||||
2021-11-19 14:15:57;"LOGIN_SUCCESSFUL";;"[peter.process]";"193.26.202.162";"2021-11-19 15:15:57";"[ddb6d6788ac1e42bc55ed8282e137377]";"[UMC]" | ||||||||||||||
2021-11-19 14:04:35;"LOGIN_SUCCESSFUL";;"[eric.employee]";"193.26.202.162";"2021-11-19 15:04:35";"[6294768663ce59aaa62d834b5f30ae79]";"[UMC]" | ||||||||||||||
2021-11-19 13:43:59;"LOGIN_SUCCESSFUL";;"[danny.designer]";"193.26.202.162";"2021-11-19 14:43:59";"[b13b062997f15669778dacbb5669f59e]";"[UMC]" | ||||||||||||||
2021-11-04 21:00:14;"LOGIN_SUCCESSFUL";;"[amy.architecture]";"193.26.202.162";"2021-11-04 22:00:14";"[602f9b9852d8c2a800d67a848721f1bf]";"[UMC]" | ||||||||||||||
2021-11-04 20:40:38;"LOGIN_SUCCESSFUL";;"[danny.designer]";"193.26.202.162";"2021-11-04 21:40:38";"[5f494adbefa24059e66db1dafa147677]";"[UMC]" | ||||||||||||||
2021-11-04 20:21:08;"LOGIN_SUCCESSFUL";;"[danny.designer]";"193.26.202.162";"2021-11-04 21:21:08";"[afc0a2a067f674d1f35bb555ff979a30]";"[UMC]" | ||||||||||||||
2021-11-03 11:23:43;"LOGIN_SUCCESSFUL";;"[eric.employee]";"193.26.202.162";"2021-11-03 12:23:43";"[9a1cb45e9c210638ed8d3cc6886b91ab]";"[UMC]" | ||||||||||||||
2021-11-03 11:19:29;"LOGIN_SUCCESSFUL";;"[danny.designer]";"193.26.202.162";"2021-11-03 12:19:29";"[952f12c6bbfe7babb950c591a403fee6]";"[UMC]" |
Cheers
Rune
Hey Rune,
Thanks for your answer.
Actually I'm in interested in the last login date of each user on a specific database and not the number of users who logged in as you said.
I did what you said but I got an Excel file with only users first/last name and permissions. No infos about login.
Cheers
Hi Veronika,
Thank you for your answer.
What I meant is that I need to retrieve the last active session of each user with a report. I looked for functions on Aris script that would help me get this but I didn't find any.
If you know more on the subject, I'd like to know.
Thank you !
Hi, Please see the code below. When creating the script, make sure you select to run it from a group and that you can open dialogs, output is to Excel. Run the script from the "Main group".
var LNG = Context.getSelectedLanguage();
var AD = ArisData.getActiveDatabase();
var AF = AD.ActiveFilter();
var currentDate = new Date();
var minutes = currentDate.getMinutes();
var allGroups = new Array();
var selDBSName = AD.Name(LNG);
var selGroupName = ArisData.getSelectedGroups()[0].Name(LNG);
var modsinGroup = new Array();
var userName = "";
var gUsers = AD.UserList();
var UsersL = new Array();
//////////////////////////////////////
function main()
{
for (var n = 0; n < gUsers.length; n++) {
var uName = gUsers[n].Name(LNG)
if (uName == "guest" || uName == "arisservice" || uName == "superuser") {
continue;
} else {
UsersL = UsersL.concat(uName);
}
}
UsersL = UsersL.sort();
var userdialogUserName = Dialogs.createNewDialogTemplate(150, 50, "User name");
userdialogUserName.Text(10, 10, 100, 15, "Select User Name:");
userdialogUserName.ComboBox(10, 30, 170, 15, UsersL,"sSelectedItem");
userdialogUserName.OKButton();
userdialogUserName.CancelButton();
var dlgIG = Dialogs.createUserDialog(userdialogUserName);
userdialogUserName = Dialogs.show( __currentDialog = dlgIG);
if (userdialogUserName == 0) {
return;
}
var userNr = dlgIG.getDlgSelection("sSelectedItem");
userName = UsersL[userNr];
var groups = ArisData.getSelectedGroups();
var modelList = ArisData.getSelectedModels();
for (var a=0;a<groups.length;a++) {
var group = groups[a];
allGroups = allGroups.concat(groups[a]);
var childGroups = group.Childs(true);
if (childGroups.length > 0) {
for (var c = 0; c < childGroups.length; c++) {
allGroups.push(childGroups[c]);
}
}
}
createReport(userName);
}
/////////////////////////////////
function createReport(userName)
{
var fileName = "Last updates by " + userName;
var extension = ".xlsx";
OUTEXCEL = Context.createOutputObject(Context.getSelectedFormat(), fileName + " in " + selDBSName + "-" + selGroupName + extension);
OUTEXCEL.Init(LNG);
OUTEXCEL.DefineF("NORMAL", "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT | Constants.FMT_VTOP, 0, 1, 0, 0, 0, 1);
OUTEXCEL.DefineF("TABLE_HEAD_GREY", "Arial", 9, Constants.C_BLACK, Constants.C_GREY_80_PERCENT, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VCENTER, 0, 0, 0, 0, 0, 1);
InitStatusReport();
getAttribs();
OUTEXCEL.EndTable("Attributes", 100, "Arial", 12, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
OUTEXCEL.WriteReport();
}
////////////////////////////////
function InitStatusReport()
{
OUTEXCEL.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0);
OUTEXCEL.TableRow();
OUTEXCEL.TableCellF("User Name", 50, "TABLE_HEAD_GREY");
OUTEXCEL.TableCellF("Model Name", 50, "TABLE_HEAD_GREY");
OUTEXCEL.TableCellF("Model Type", 50, "TABLE_HEAD_GREY");
OUTEXCEL.TableCellF("Date changed", 50, "TABLE_HEAD_GREY");
//OUTEXCEL.TableCellF("Hieracrhy Number", 20, "TABLE_HEAD_GREY");
//OUTEXCEL.TableCellF("Rule Type", 50, "TABLE_HEAD_GREY");
}
////////////////////////////////
function getAttribs()
{
allGroups = ArisData.sort(allGroups, Constants.AT_NAME, LNG);
for (var z = 0; z < allGroups.length; z++) {
var grp = allGroups[z];
modelList = grp.ModelList();
modelList = ArisData.sort(modelList, Constants.AT_NAME, LNG);
for (var b = 0; b < modelList.length; b++) {
var aModel = modelList[b];
var user = aModel.Attribute(Constants.AT_LUSER, LNG).getValue();
if (user == userName) {
var aName = user;
var aModName = aModel.Attribute(Constants.AT_NAME, LNG).getValue();
var aType = aModel.Type();
var aDate = aModel.Attribute(Constants.AT_LAST_CHNG_2, LNG).getValue();
WriteReportLine(aName, aModName, aType, aDate);
}
}
}
}
////////////////////////////////
function WriteReportLine(aName, aModName, aType, aDate) //, oTXCode, oDesc)
{
OUTEXCEL.TableRow();
OUTEXCEL.TableCellF(aName, 50, "NORMAL");
OUTEXCEL.TableCellF(aModName, 50, "NORMAL");
OUTEXCEL.TableCellF(aType, 50, "NORMAL");
OUTEXCEL.TableCellF(aDate, 50, "NORMAL");
//OUTEXCEL.TableCellF(aHierArch, 20, "NORMAL");
//OUTEXCEL.TableCellF(oRuleType, 50, "NORMAL");
}
////////////////////////////////
main();
Hope it helps.
Regards,
Willem