Child pages
  • Security

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Div
styledisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

Div
iddescription



HTML Table
id
classservoy sReturnTypes
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Return Types
Table Row (tr)
Table Cell (td)
 



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Summary
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
ACCESSIBLE
Constant representing the accessible flag for form security.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
DELETE
Constant representing the delete flag for table security.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
INSERT
Constant representing the insert flag for table security.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
READ
Constant representing the read flag for table security.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
TRACKING
Constant representing the tracking flag for table security (tracks sql insert/update/delete).
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
TRACKING_VIEWS
Constant representing the tracking flag for table security (tracks sql select).
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
UPDATE
Constant representing the update flag for table security.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
VIEWABLE
Constant representing the viewable flag for form security.



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
addUserToGroup(a_userUID, groupName)
Adds an user to a named group.
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
authenticate(authenticator_solution, method)
Authenticate to the Servoy Server using one of the installed authenticators or the Servoy default authenticator.
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
authenticate(authenticator_solution, method, credentials)
Authenticate to the Servoy Server using one of the installed authenticators or the Servoy default authenticator.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
canDelete(dataSource)
Returns a boolean value for security rights.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
canInsert(dataSource)
Returns a boolean value for security rights.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
canRead(dataSource)
Returns a boolean value for security rights.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
canUpdate(dataSource)
Returns a boolean value for security rights.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
changeGroupName(oldGroupName, newGroupName)
Changes the groupname of a group.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
changeUserName(a_userUID, username)
Changes the username of the specified userUID.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
checkPassword(a_userUID, password)
Returns true if the password for that userUID is correct, else false.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
createGroup(groupName)
Creates a group, returns the groupname (or null when group couldn't be created).
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
createUser(username, password)
Creates a new user, returns new uid (or null when group couldn't be created or user alreay exist).
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
createUser(username, password, userUID)
Creates a new user, returns new uid (or null when group couldn't be created or user alreay exist).
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
deleteGroup(groupName)
Deletes a group, returns true if no error was reported.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
deleteUser(userUID)
Deletes an user.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getClientID()
Returns the client ID.
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
getElementUUIDs(formname)
Returns the form elements UUID's as dataset, the one with no name is the form itself.
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
getGroups()
Get all the groups (returns a dataset).
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getSystemUserName()
Retrieves the username of the currently logged in user on operating system level.
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
getUserGroups()
Get all the groups of the current user.
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
getUserGroups(userUID)
Get all the groups for given user UID.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getUserName()
Get the current user name (null if not logged in), finds the user name for given user UID if passed as parameter.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getUserName(userUID)
Get the current user name (null if not logged in), finds the user name for given user UID if passed as parameter.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getUserUID()
Get the current user UID (null if not logged in); finds the userUID for given user_name if passed as parameter.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getUserUID(username)
Get the current user UID (null if not logged in); finds the userUID for given user_name if passed as parameter.
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
getUsers()
Get all the users in the security settings (returns a dataset).
Table Row (tr)
Table Cell (td)
JSDataSet
Table Cell (td)
getUsers(groupName)
Get all the users in the security settings (returns a dataset).
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
isUserMemberOfGroup(groupName)
Check whatever the current user is part of the specified group
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
isUserMemberOfGroup(groupName, userUID)
Check whatever the user specified as parameter is part of the specified group.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
login(username, a_userUID, groups)
Login to be able to leave the solution loginForm.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
logout()
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
logout(solutionToLoad)
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
logout(solutionToLoad, method)
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
logout(solutionToLoad, method, argument)
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
removeUserFromGroup(a_userUID, groupName)
Removes an user from a group.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
setPassword(a_userUID, password)
Set a new password for the given userUID.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
setSecuritySettings(dataset)
Sets the security settings; the entries contained in the given dataset will override those contained in the current security settings.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
setUserUID(a_userUID, newUserUID)
Set a new userUID for the given userUID.



HTML Table
idconstant
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Details
Table Body (tbody)
idACCESSIBLE
Table Row (tr)
idname
Table Cell (td)

ACCESSIBLE

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the accessible flag for form security.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idDELETE
Table Row (tr)
idname
Table Cell (td)

DELETE

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the delete flag for table security.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idINSERT
Table Row (tr)
idname
Table Cell (td)

INSERT

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the insert flag for table security.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idREAD
Table Row (tr)
idname
Table Cell (td)

READ

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the read flag for table security.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idTRACKING
Table Row (tr)
idname
Table Cell (td)

TRACKING

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the tracking flag for table security (tracks sql insert/update/delete).
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idTRACKING_VIEWS
Table Row (tr)
idname
Table Cell (td)

TRACKING_VIEWS

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the tracking flag for table security (tracks sql select).
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idUPDATE
Table Row (tr)
idname
Table Cell (td)

UPDATE

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the update flag for table security.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idVIEWABLE
Table Row (tr)
idname
Table Cell (td)

VIEWABLE

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant representing the viewable flag for form security.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 



HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idaddUserToGroup-Object_Object
Table Row (tr)
idname
Table Cell (td)

addUserToGroup

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
addUserToGroup
Span
(a_userUID, groupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Adds an user to a named group.
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} a_userUID - the user UID to be added
{Object} groupName - the group to add to
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if added
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var userUID = security.getUserUID();
security.addUserToGroup(userUID, 'groupname');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idauthenticate-String_String
Table Row (tr)
idname
Table Cell (td)

authenticate

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
authenticate
Span
(authenticator_solution, method)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Authenticate to the Servoy Server using one of the installed authenticators or the Servoy default authenticator.

Note: this method should be called from a login solution.

Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} authenticator_solution - authenticator solution installed on the Servoy Server, null for servoy built-in authentication
{String} method - authenticator method, null for servoy built-in authentication
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - authentication result from authenticator solution or boolean in case of servoy built-in authentication
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// create the credentials object as expected by the authenticator solution
var ok =  security.authenticate('myldap_authenticator', 'login', [scopes.globals.userName, scopes.globals.passWord])
if (!ok)
{
	plugins.dialogs.showErrorDialog('Login failed', 'OK')
}

// if no authenticator name is used, the credentials are checked using the Servoy built-in user management
ok = security.authenticate(null, null, [scopes.globals.userName, scopes.globals.passWord])
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idauthenticate-String_String_ObjectArray
Table Row (tr)
idname
Table Cell (td)

authenticate

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
authenticate
Span
(authenticator_solution, method, credentials)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Authenticate to the Servoy Server using one of the installed authenticators or the Servoy default authenticator.

Note: this method should be called from a login solution, once logged in, the authenticate method has no effect.

Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} authenticator_solution - authenticator solution installed on the Servoy Server, null for servoy built-in authentication
{String} method - authenticator method, null for servoy built-in authentication
{Object[]} credentials - array whose elements are passed as arguments to the authenticator method, in case of servoy built-in authentication this should be [username, password]
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - authentication result from authenticator solution or boolean in case of servoy built-in authentication
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// create the credentials object as expected by the authenticator solution
var ok =  security.authenticate('myldap_authenticator', 'login', [scopes.globals.userName, scopes.globals.passWord])
if (!ok)
{
	plugins.dialogs.showErrorDialog('Login failed', 'OK')
}

// if no authenticator name is used, the credentials are checked using the Servoy built-in user management
ok = security.authenticate(null, null, [scopes.globals.userName, scopes.globals.passWord])
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcanDelete-String
Table Row (tr)
idname
Table Cell (td)

canDelete

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
canDelete
Span
(dataSource)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a boolean value for security rights.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} dataSource - the datasource
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if allowed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var dataSource = controller.getDataSource();
var canDelete = security.canDelete(dataSource);
var canInsert = security.canInsert(dataSource);
var canUpdate = security.canUpdate(dataSource);
var canRead = security.canRead(dataSource);
application.output("Can delete? " + canDelete);
application.output("Can insert? " + canInsert);
application.output("Can update? " + canUpdate);
application.output("Can read? " + canRead);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcanInsert-String
Table Row (tr)
idname
Table Cell (td)

canInsert

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
canInsert
Span
(dataSource)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a boolean value for security rights.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} dataSource - the datasource
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if allowed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var dataSource = controller.getDataSource();
var canDelete = security.canDelete(dataSource);
var canInsert = security.canInsert(dataSource);
var canUpdate = security.canUpdate(dataSource);
var canRead = security.canRead(dataSource);
application.output("Can delete? " + canDelete);
application.output("Can insert? " + canInsert);
application.output("Can update? " + canUpdate);
application.output("Can read? " + canRead);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcanRead-String
Table Row (tr)
idname
Table Cell (td)

canRead

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
canRead
Span
(dataSource)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a boolean value for security rights.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} dataSource - the datasource
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if allowed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var dataSource = controller.getDataSource();
var canDelete = security.canDelete(dataSource);
var canInsert = security.canInsert(dataSource);
var canUpdate = security.canUpdate(dataSource);
var canRead = security.canRead(dataSource);
application.output("Can delete? " + canDelete);
application.output("Can insert? " + canInsert);
application.output("Can update? " + canUpdate);
application.output("Can read? " + canRead);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcanUpdate-String
Table Row (tr)
idname
Table Cell (td)

canUpdate

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
canUpdate
Span
(dataSource)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a boolean value for security rights.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} dataSource - the datasource
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if allowed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var dataSource = controller.getDataSource();
var canDelete = security.canDelete(dataSource);
var canInsert = security.canInsert(dataSource);
var canUpdate = security.canUpdate(dataSource);
var canRead = security.canRead(dataSource);
application.output("Can delete? " + canDelete);
application.output("Can insert? " + canInsert);
application.output("Can update? " + canUpdate);
application.output("Can read? " + canRead);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idchangeGroupName-Object_String
Table Row (tr)
idname
Table Cell (td)

changeGroupName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
changeGroupName
Span
(oldGroupName, newGroupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Changes the groupname of a group.
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} oldGroupName - the old name
{String} newGroupName - the new name
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if changed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
security.changeGroupName('oldGroup', 'newGroup');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idchangeUserName-Object_String
Table Row (tr)
idname
Table Cell (td)

changeUserName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
changeUserName
Span
(a_userUID, username)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Changes the username of the specified userUID.
Note: this method can only be called by an admin user or a normal logged in user changing its own userName.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} a_userUID - the userUID to work on
{String} username - the new username
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if changed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
if(security.changeUserName(security.getUserUID('name1'), 'name2'))
{
	application.output('Username changed');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcheckPassword-Object_String
Table Row (tr)
idname
Table Cell (td)

checkPassword

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
checkPassword
Span
(a_userUID, password)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the password for that userUID is correct, else false.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} a_userUID - the userUID to check the password for
{String} password - the new password
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if password oke
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
if(security.checkPassword(security.getUserUID(), 'password1'))
{
	security.setPassword(security.getUserUID(), 'password2')
}
else
{
	application.output('wrong password')
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcreateGroup-String
Table Row (tr)
idname
Table Cell (td)

createGroup

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
createGroup
Span
(groupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a group, returns the groupname (or null when group couldn't be created).
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} groupName - the group name to create
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the created groupname
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var deleteGroup = true;
//ceate a group
var groupName = security.createGroup('myGroup');
if (groupName)
{
	//create a user
	var uid = security.createUser('myusername', 'mypassword');
	if (uid) //test if user was created
	{
		//set a newUID for the user
		var isChanged = security.setUserUID(uid,'myUserUID')
		// add user to group
		security.addUserToGroup(uid, groupName);
		// if not delete group, do delete group
		if (deleteGroup)
		{
			security.deleteGroup(groupName);
		}
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcreateUser-String_String
Table Row (tr)
idname
Table Cell (td)

createUser

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
createUser
Span
(username, password)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a new user, returns new uid (or null when group couldn't be created or user alreay exist).
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} username - the username
{String} password - the user password
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - the userUID the created userUID, will be same if provided
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var removeUser = true;
//create a user
var uid = security.createUser('myusername', 'mypassword');
if (uid) //test if user was created
{
	// Get all the groups
	var set = security.getGroups();
	for(var p = 1 ; p <= set.getMaxRowIndex() ; p++)
	{
		// output name of the group
		application.output(set.getValue(p, 2));
		// add user to group
		security.addUserToGroup(uid, set.getValue(p,2));
	}
	// if not remove user, remove user from all the groups
	if(!removeUser)
	{
		// get now all the groups that that users has (all if above did go well)
		var set =security.getUserGroups(uid);
		for(var p = 1;p<=set.getMaxRowIndex();p++)
		{
			// output name of the group
			application.output(set.getValue(p, 2));
			// remove the user from the group
			security.removeUserFromGroup(uid, set.getValue(p,2));
		}
	}
	else
	{
		// delete the user (the user will be removed from the groups)
		security.deleteUser(uid);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcreateUser-String_String_Object
Table Row (tr)
idname
Table Cell (td)

createUser

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
createUser
Span
(username, password, userUID)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a new user, returns new uid (or null when group couldn't be created or user alreay exist).
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} username - the username
{String} password - the user password
{Object} userUID - the user UID to use
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - the userUID the created userUID, will be same if provided
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var removeUser = true;
//create a user
var uid = security.createUser('myusername', 'mypassword');
if (uid) //test if user was created
{
	// Get all the groups
	var set = security.getGroups();
	for(var p = 1 ; p <= set.getMaxRowIndex() ; p++)
	{
		// output name of the group
		application.output(set.getValue(p, 2));
		// add user to group
		security.addUserToGroup(uid, set.getValue(p,2));
	}
	// if not remove user, remove user from all the groups
	if(!removeUser)
	{
		// get now all the groups that that users has (all if above did go well)
		var set =security.getUserGroups(uid);
		for(var p = 1;p<=set.getMaxRowIndex();p++)
		{
			// output name of the group
			application.output(set.getValue(p, 2));
			// remove the user from the group
			security.removeUserFromGroup(uid, set.getValue(p,2));
		}
	}
	else
	{
		// delete the user (the user will be removed from the groups)
		security.deleteUser(uid);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddeleteGroup-Object
Table Row (tr)
idname
Table Cell (td)

deleteGroup

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
deleteGroup
Span
(groupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Deletes a group, returns true if no error was reported.
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} groupName - the name of the group to delete
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if deleted
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var deleteGroup = true;
//ceate a group
var groupName = security.createGroup('myGroup');
if (groupName)
{
	//create a user
	var uid = security.createUser('myusername', 'mypassword');
	if (uid) //test if user was created
	{
		//set a newUID for the user
		var isChanged = security.setUserUID(uid,'myUserUID')
		// add user to group
		security.addUserToGroup(uid, groupName);
		// if not delete group, do delete group
		if (deleteGroup)
		{
			security.deleteGroup(groupName);
		}
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddeleteUser-Object
Table Row (tr)
idname
Table Cell (td)

deleteUser

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
deleteUser
Span
(userUID)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Deletes an user. returns true if no error was reported.
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} userUID - The UID of the user to be deleted.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if the user is successfully deleted.
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var removeUser = true;
//create a user
var uid = security.createUser('myusername', 'mypassword');
if (uid) //test if user was created
{
	// Get all the groups
	var set = security.getGroups();
	for(var p = 1 ; p <= set.getMaxRowIndex() ; p++)
	{
		// output name of the group
		application.output(set.getValue(p, 2));
		// add user to group
		security.addUserToGroup(uid, set.getValue(p,2));
	}
	// if not remove user, remove user from all the groups
	if(!removeUser)
	{
		// get now all the groups that that users has (all if above did go well)
		var set =security.getUserGroups(uid);
		for(var p = 1;p<=set.getMaxRowIndex();p++)
		{
			// output name of the group
			application.output(set.getValue(p, 2));
			// remove the user from the group
			security.removeUserFromGroup(uid, set.getValue(p,2));
		}
	}
	else
	{
		// delete the user (the user will be removed from the groups)
		security.deleteUser(uid);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetClientID
Table Row (tr)
idname
Table Cell (td)

getClientID

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getClientID
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the client ID.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the clientId as seen on the server admin page
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var clientId = security.getClientID()
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetElementUUIDs-String
Table Row (tr)
idname
Table Cell (td)

getElementUUIDs

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
getElementUUIDs
Span
(formname)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the form elements UUID's as dataset, the one with no name is the form itself.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} formname - the formname to retieve the dataset for
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSDataSet - dataset with element info
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var formElementsUUIDDataSet = security.getElementUUIDs('orders_form');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetGroups
Table Row (tr)
idname
Table Cell (td)

getGroups

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
getGroups
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get all the groups (returns a dataset).
first id column is deprecated!, use only the group name column.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSDataSet - dataset with all the groups
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var removeUser = true;
//create a user
var uid = security.createUser('myusername', 'mypassword');
if (uid) //test if user was created
{
	// Get all the groups
	var set = security.getGroups();
	for(var p = 1 ; p <= set.getMaxRowIndex() ; p++)
	{
		// output name of the group
		application.output(set.getValue(p, 2));
		// add user to group
		security.addUserToGroup(uid, set.getValue(p,2));
	}
	// if not remove user, remove user from all the groups
	if(!removeUser)
	{
		// get now all the groups that that users has (all if above did go well)
		var set =security.getUserGroups(uid);
		for(var p = 1;p<=set.getMaxRowIndex();p++)
		{
			// output name of the group
			application.output(set.getValue(p, 2));
			// remove the user from the group
			security.removeUserFromGroup(uid, set.getValue(p,2));
		}
	}
	else
	{
		// delete the user (the user will be removed from the groups)
		security.deleteUser(uid);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetSystemUserName
Table Row (tr)
idname
Table Cell (td)

getSystemUserName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getSystemUserName
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Retrieves the username of the currently logged in user on operating system level.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the os user name
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//gets the current os username
var osUserName = security.getSystemUserName();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUserGroups
Table Row (tr)
idname
Table Cell (td)

getUserGroups

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
getUserGroups
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get all the groups of the current user.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSDataSet - dataset with groupnames
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//get all the users in the security settings (Returns a JSDataset)
var dsUsers = security.getUsers()

//loop through each user to get their group
//The getValue call is (row,column) where column 1 == id and 2 == name
for(var i=1 ; i<=dsUsers.getMaxRowIndex() ; i++)
{
	//print to the output debugger tab: "user: " and the username
	application.output("user:" + dsUsers.getValue(i,2));

	//set p to the user group for the current user
	/** @type {JSDataSet} */
	var p = security.getUserGroups(dsUsers.getValue(i,1));

	for(k=1;k<=p.getMaxRowIndex();k++)
	{
		//print to the output debugger tab: "group" and the group(s)
		//the user belongs to
		application.output("group: " + p.getValue(k,2));
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUserGroups-Object
Table Row (tr)
idname
Table Cell (td)

getUserGroups

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
getUserGroups
Span
(userUID)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get all the groups for given user UID.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} userUID - to retrieve the user groups
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSDataSet - dataset with groupnames
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//get all the users in the security settings (Returns a JSDataset)
var dsUsers = security.getUsers()

//loop through each user to get their group
//The getValue call is (row,column) where column 1 == id and 2 == name
for(var i=1 ; i<=dsUsers.getMaxRowIndex() ; i++)
{
	//print to the output debugger tab: "user: " and the username
	application.output("user:" + dsUsers.getValue(i,2));

	//set p to the user group for the current user
	/** @type {JSDataSet} */
	var p = security.getUserGroups(dsUsers.getValue(i,1));

	for(k=1;k<=p.getMaxRowIndex();k++)
	{
		//print to the output debugger tab: "group" and the group(s)
		//the user belongs to
		application.output("group: " + p.getValue(k,2));
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUserName
Table Row (tr)
idname
Table Cell (td)

getUserName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getUserName
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the current user name (null if not logged in), finds the user name for given user UID if passed as parameter.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the user name
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//gets the current loggedIn username
var userName = security.getUserName();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUserName-Object
Table Row (tr)
idname
Table Cell (td)

getUserName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getUserName
Span
(userUID)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the current user name (null if not logged in), finds the user name for given user UID if passed as parameter.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} userUID - the user UID used to retrieve the name
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the user name
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//gets the current loggedIn username
var userName = security.getUserName();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUserUID
Table Row (tr)
idname
Table Cell (td)

getUserUID

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getUserUID
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the current user UID (null if not logged in); finds the userUID for given user_name if passed as parameter.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the userUID
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//gets the current loggedIn username
var userName = security.getUserName();
//gets the uid of the given username
var userUID = security.getUserUID(userName);
//is the same as above
//var my_userUID = security.getUserUID();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUserUID-String
Table Row (tr)
idname
Table Cell (td)

getUserUID

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getUserUID
Span
(username)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the current user UID (null if not logged in); finds the userUID for given user_name if passed as parameter.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} username - the username to find the userUID for
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the userUID
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//gets the current loggedIn username
var userName = security.getUserName();
//gets the uid of the given username
var userUID = security.getUserUID(userName);
//is the same as above
//var my_userUID = security.getUserUID();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUsers
Table Row (tr)
idname
Table Cell (td)

getUsers

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
getUsers
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get all the users in the security settings (returns a dataset).
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSDataSet - dataset with all the users
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//get all the users in the security settings (Returns a JSDataset)
var dsUsers = security.getUsers()

//loop through each user to get their group
//The getValue call is (row,column) where column 1 == id and 2 == name
for(var i=1 ; i<=dsUsers.getMaxRowIndex() ; i++)
{
	//print to the output debugger tab: "user: " and the username
	application.output("user:" + dsUsers.getValue(i,2));

	//set p to the user group for the current user
	/** @type {JSDataSet} */
	var p = security.getUserGroups(dsUsers.getValue(i,1));

	for(k=1;k<=p.getMaxRowIndex();k++)
	{
		//print to the output debugger tab: "group" and the group(s)
		//the user belongs to
		application.output("group: " + p.getValue(k,2));
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUsers-String
Table Row (tr)
idname
Table Cell (td)

getUsers

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSDataSet
Span
stylefont-weight: bold;
getUsers
Span
(groupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get all the users in the security settings (returns a dataset).
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} groupName - the group to filter on
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSDataSet - dataset with all the users
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//get all the users in the security settings (Returns a JSDataset)
var dsUsers = security.getUsers()

//loop through each user to get their group
//The getValue call is (row,column) where column 1 == id and 2 == name
for(var i=1 ; i<=dsUsers.getMaxRowIndex() ; i++)
{
	//print to the output debugger tab: "user: " and the username
	application.output("user:" + dsUsers.getValue(i,2));

	//set p to the user group for the current user
	/** @type {JSDataSet} */
	var p = security.getUserGroups(dsUsers.getValue(i,1));

	for(k=1;k<=p.getMaxRowIndex();k++)
	{
		//print to the output debugger tab: "group" and the group(s)
		//the user belongs to
		application.output("group: " + p.getValue(k,2));
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisUserMemberOfGroup-String
Table Row (tr)
idname
Table Cell (td)

isUserMemberOfGroup

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isUserMemberOfGroup
Span
(groupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Check whatever the current user is part of the specified group
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} groupName - name of the group to check
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - dataset with groupnames
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//check whatever user is part of the Administrators group
if(security.isUserMemberOfGroup('Administrators', security.getUserUID('admin')))
{
	// do administration stuff
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisUserMemberOfGroup-String_Object
Table Row (tr)
idname
Table Cell (td)

isUserMemberOfGroup

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isUserMemberOfGroup
Span
(groupName, userUID)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Check whatever the user specified as parameter is part of the specified group.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} groupName - name of the group to check
{Object} userUID - UID of the user to check
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - dataset with groupnames
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//check whatever user is part of the Administrators group
if(security.isUserMemberOfGroup('Administrators', security.getUserUID('admin')))
{
	// do administration stuff
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlogin-String_Object_StringArray
Table Row (tr)
idname
Table Cell (td)

login

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
login
Span
(username, a_userUID, groups)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Login to be able to leave the solution loginForm.

Example: Group names may be received from LDAP (Lightweight Directory Access Protocol) - a standard protocol used in web browsers and email applications to enable lookup queries that access a directory listing.

Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} username - the username, like 'JamesWebb'
{Object} a_userUID - the user UID to process login for
{String[]} groups - the groups array
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if loggedin
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var groups = ['Administrators']; //normally these groups are for example received from LDAP
var user_uid = scopes.globals.email; //also this uid might be received from external authentication method
var ok =  security.login(scopes.globals.username, user_uid , groups)
if (!ok)
{
	plugins.dialogs.showErrorDialog('Login failure',  'Already logged in? or no user_uid/groups specified?', 'OK')
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlogout
Table Row (tr)
idname
Table Cell (td)

logout

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
logout
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
You can redirect to another solution if needed; if you want to go to a different url, you need to call application.showURL(url) before calling security.logout() (this is only applicable for Web Client).
An alternative option to close a solution and to open another solution, while keeping the user logged in, is application.closeSolution().
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//Set the url to go to after logout.
//application.showURL('http://www.servoy.com', '_self');  //Web Client only
security.logout();
//security.logout('solution_name');//log out and close current solution and open solution 'solution_name'
//security.logout('solution_name','global_method_name');//log out, close current solution, open solution 'solution_name' and call global method 'global_method_name' of the newly opened solution
//security.logout('solution_name','global_method_name','my_string_argument');//log out, close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'
//security.logout('solution_name','global_second_method_name',2);
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlogout-String
Table Row (tr)
idname
Table Cell (td)

logout

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
logout
Span
(solutionToLoad)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
You can redirect to another solution if needed; if you want to go to a different url, you need to call application.showURL(url) before calling security.logout() (this is only applicable for Web Client).
An alternative option to close a solution and to open another solution, while keeping the user logged in, is application.closeSolution().
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} solutionToLoad - the solution to load after logout
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//Set the url to go to after logout.
//application.showURL('http://www.servoy.com', '_self');  //Web Client only
security.logout();
//security.logout('solution_name');//log out and close current solution and open solution 'solution_name'
//security.logout('solution_name','global_method_name');//log out, close current solution, open solution 'solution_name' and call global method 'global_method_name' of the newly opened solution
//security.logout('solution_name','global_method_name','my_string_argument');//log out, close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'
//security.logout('solution_name','global_second_method_name',2);
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlogout-String_String
Table Row (tr)
idname
Table Cell (td)

logout

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
logout
Span
(solutionToLoad, method)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
You can redirect to another solution if needed; if you want to go to a different url, you need to call application.showURL(url) before calling security.logout() (this is only applicable for Web Client).
An alternative option to close a solution and to open another solution, while keeping the user logged in, is application.closeSolution().
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} solutionToLoad - the solution to load after logout
{String} method - the method to run in the solution to load
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//Set the url to go to after logout.
//application.showURL('http://www.servoy.com', '_self');  //Web Client only
security.logout();
//security.logout('solution_name');//log out and close current solution and open solution 'solution_name'
//security.logout('solution_name','global_method_name');//log out, close current solution, open solution 'solution_name' and call global method 'global_method_name' of the newly opened solution
//security.logout('solution_name','global_method_name','my_string_argument');//log out, close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'
//security.logout('solution_name','global_second_method_name',2);
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlogout-String_String_Object
Table Row (tr)
idname
Table Cell (td)

logout

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
logout
Span
(solutionToLoad, method, argument)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Logout the current user and close the solution, if the solution requires authentication and user is logged in.
You can redirect to another solution if needed; if you want to go to a different url, you need to call application.showURL(url) before calling security.logout() (this is only applicable for Web Client).
An alternative option to close a solution and to open another solution, while keeping the user logged in, is application.closeSolution().
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} solutionToLoad - the solution to load after logout
{String} method - the method to run in the solution to load
{Object} argument - the argument to pass to the method to run
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//Set the url to go to after logout.
//application.showURL('http://www.servoy.com', '_self');  //Web Client only
security.logout();
//security.logout('solution_name');//log out and close current solution and open solution 'solution_name'
//security.logout('solution_name','global_method_name');//log out, close current solution, open solution 'solution_name' and call global method 'global_method_name' of the newly opened solution
//security.logout('solution_name','global_method_name','my_string_argument');//log out, close current solution, open solution 'solution_name', call global method 'global_method_name' with argument 'my_argument'
//security.logout('solution_name','global_second_method_name',2);
//Note: specifying a solution will not work in the Developer due to debugger dependencies
//specified solution should be of compatible type with client (normal type or client specific(Smart client only/Web client only) type )
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idremoveUserFromGroup-Object_Object
Table Row (tr)
idname
Table Cell (td)

removeUserFromGroup

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
removeUserFromGroup
Span
(a_userUID, groupName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Removes an user from a group.
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} a_userUID - the user UID to be removed
{Object} groupName - the group to remove from
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if removed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var removeUser = true;
//create a user
var uid = security.createUser('myusername', 'mypassword');
if (uid) //test if user was created
{
	// Get all the groups
	var set = security.getGroups();
	for(var p = 1 ; p <= set.getMaxRowIndex() ; p++)
	{
		// output name of the group
		application.output(set.getValue(p, 2));
		// add user to group
		security.addUserToGroup(uid, set.getValue(p,2));
	}
	// if not remove user, remove user from all the groups
	if(!removeUser)
	{
		// get now all the groups that that users has (all if above did go well)
		var set =security.getUserGroups(uid);
		for(var p = 1;p<=set.getMaxRowIndex();p++)
		{
			// output name of the group
			application.output(set.getValue(p, 2));
			// remove the user from the group
			security.removeUserFromGroup(uid, set.getValue(p,2));
		}
	}
	else
	{
		// delete the user (the user will be removed from the groups)
		security.deleteUser(uid);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetPassword-Object_String
Table Row (tr)
idname
Table Cell (td)

setPassword

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
setPassword
Span
(a_userUID, password)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Set a new password for the given userUID.
Note: this method can only be called by an admin user or a normal logged in user changing its own password.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} a_userUID - the userUID to set the new password for
{String} password - the new password
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if changed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
if(security.checkPassword(security.getUserUID(), 'password1'))
{
	security.setPassword(security.getUserUID(), 'password2')
}
else
{
	application.output('wrong password')
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetSecuritySettings-Object
Table Row (tr)
idname
Table Cell (td)

setSecuritySettings

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
setSecuritySettings
Span
(dataset)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Sets the security settings; the entries contained in the given dataset will override those contained in the current security settings.

NOTE: The security.getElementUUIDs and security.setSecuritySettings functions can be used to define custom security that overrides Servoy security.
For additional information see the function security.getElementUUIDs.

Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} dataset - the dataset with security settings
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var colNames = new Array();
colNames[0] = 'uuid';
colNames[1] = 'flags';
var dataset = databaseManager.createEmptyDataSet(0,colNames);

var row = new Array();
row[0] = '413a4d69-becb-4ae4-8fdd-980755d6a7fb';//normally retreived via security.getElementUUIDs(...)
row[1] = JSSecurity.VIEWABLE|JSSecurity.ACCESSIBLE; // use bitwise 'or' for both
dataset.addRow(row);//setting element security

row = new Array();
row[0] = 'example_data.orders';
row[1] = JSSecurity.READ|JSSecurity.INSERT|JSSecurity.UPDATE|JSSecurity.DELETE|JSSecurity.TRACKING; //use bitwise 'or' for multiple flags
dataset.addRow(row);//setting table security

security.setSecuritySettings(dataset);//to be called in solution startup method
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetUserUID-Object_String
Table Row (tr)
idname
Table Cell (td)

setUserUID

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
setUserUID
Span
(a_userUID, newUserUID)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Set a new userUID for the given userUID.
Note: this method can only be called by an admin.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} a_userUID - the userUID to set the new user UID for
{String} newUserUID - the new user UID
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if changed
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var deleteGroup = true;
//ceate a group
var groupName = security.createGroup('myGroup');
if (groupName)
{
	//create a user
	var uid = security.createUser('myusername', 'mypassword');
	if (uid) //test if user was created
	{
		//set a newUID for the user
		var isChanged = security.setUserUID(uid,'myUserUID')
		// add user to group
		security.addUserToGroup(uid, groupName);
		// if not delete group, do delete group
		if (deleteGroup)
		{
			security.deleteGroup(groupName);
		}
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)