setSecuritySettings does not work as expected

Hi,

I tried to set the security setting with the function security.setSecuritySetting. I made this dataset with UUIDs! This UUIDs are from security.getElementsUUID(formname) and are from the Form (first in the returned Dataset).

BufferedDataSet {Columnnames[uuid, flags]} 
row_1[caae7557-a4dc-4769-b764-9975dd3e3f09, 2] 
row_2[0d42325b-b699-49b8-9792-713b06b68c1b, 1] 
row_3[dd3e6bac-b7b5-43a3-8c1c-ed56db7fbdfb, 0] 
row_4[a05a6aaa-5045-4467-9797-aaea2a48bc5e, 2] 
row_5[c4c2b071-f070-4032-bc4e-75417eafdc73, 2] 
row_6[7dc5099b-cd98-4e18-bb60-3fae447a93f5, 1]

If I set this security setting and try to look at the form all of these are not shown. Like all got 0. But only one form should be invisible and all other should be viewable (1) or accessable (2).

Regards, Stef

Has nobody else this Problem? Who uses setSecuritySetting and how is the Dataset filled?

Regards, Stef

Stef,

The access value is a bit pattern, value 2 means accessible, but not viewable because the last bit is not set.
Try security.VIEWABLE|security.ACCESSIBLE for the fields with full access.

Rob

OK now I understand! Thanks for the help

Now I got the Problem that the Forms are not set right!

With 3 all is to see and with 0 they are not shown. But with 1 the Forms are shown and editable! How can this be?

row_1[caae7557-a4dc-4769-b764-9975dd3e3f09, 1] 
row_2[0099f4a4-e9d5-4b91-b110-f03e87bdc6e0, 1] 
row_3[4738f572-780c-43c4-bc1e-5d5ec7ffc98f, 1] 
row_4[31870021-0c5d-4fb7-b73b-c1e2b0614d4f, 1] 
row_5[338f5177-911c-4487-85c7-39fcce890dc5, 1] 
row_6[b8e82d64-eaf9-4bfc-b955-f63cf4f8811d, 1] 
row_7[58ed7634-142f-4e70-83ee-1579ec9dfd62, 1] 
row_8[b2e41ac5-2ab9-49ca-ba27-f2b53d5fde9c, 1]

I have still a problem with using the security! Has someone an suggestion where the problem can be or what mistakes I made? The security settings are not right for the forms I set it.

I am using enhanced security with an login-modul and an authenticator-modul.

On pressing login button:

function onActionLogin(event) {
	var loginResult = security.authenticate('HadesAuthenticator', 'login', [username, password]);

	if (!loginResult) {
		elements.lblLoginFaild.visible = true;
	}
}

In the authenticator-modul I am logging in the user:

function login(username, password) {
	if (!(username && password)) {
		application.output('Unexpected credentials received', LOGGINGLEVEL.DEBUG);
		return false;
	}
	
	var queryUser = "SELECT DISTINCT p.id, p.name, p.first_name, g.id, g.name\
					FROM\
						persons p\
						INNER JOIN persons_groups pg\
							ON pg.person_id = p.id\
						INNER JOIN groups g\
							ON pg.group_id = g.id\
					WHERE\
						p.usr = '" + username + "'\
						AND p.pwd= '" + password + "'"
	
	var datasetUser = databaseManager.getDataSetByQuery('hades', queryUser, null, -1);
	
	if (datasetUser != null) {
		application.output(datasetUser.getValue(1,2) + ' ' + datasetUser.getValue(1,3) + '   ' + datasetUser.getValue(1,1) + '    ' + datasetUser.getColumnAsArray(5));
		/*security.createUser(username,password,datasetUser.getValue(1,1));
		security.addUserToGroup(datasetUser.getValue(1,1),datasetUser.getValue(1,5));*/
		var ok = security.login(datasetUser.getValue(1,2) + ' ' + datasetUser.getValue(1,3), datasetUser.getValue(1,1), datasetUser.getColumnAsArray(5));
		return ok;
	}
	return false;
}

After the login was successful the onOpen method of the solution is triggerd and I initialize the security:

function secInit() {
	var queryRights = "SELECT DISTINCT r.form_name, r.form_element, r.right_value\
					FROM\
						persons_groups pg\
						INNER JOIN rights r\
							ON r.group_id = pg.group_id\
					WHERE\
						pg.person_id = " + security.getUserUID(); //security.getUserGroups().getValue(1,2)

	var datasetRights = databaseManager.getDataSetByQuery('hades', queryRights, null, -1);
	globals.prcDatasetSecurity = databaseManager.createEmptyDataSet(0, ['uuid', 'flags']);
	application.output(queryRights);
	for (var i = 1; i <= datasetRights.getMaxRowIndex(); i++) {
		forms.PrcSecurity.setSecurityToSubForms(datasetRights.getValue(i, 1),datasetRights.getValue(i, 3))
	}
	
	application.output(globals.prcDatasetSecurity);
	security.setSecuritySettings(globals.prcDatasetSecurity);
}

The Function PrcSecurity.setSecurityToSubForms returns a dataset:

row_1[caae7557-a4dc-4769-b764-9975dd3e3f09, 1] 
row_2[0099f4a4-e9d5-4b91-b110-f03e87bdc6e0, 1] 
row_3[4738f572-780c-43c4-bc1e-5d5ec7ffc98f, 1] 
row_4[31870021-0c5d-4fb7-b73b-c1e2b0614d4f, 1] 
row_5[338f5177-911c-4487-85c7-39fcce890dc5, 1] 
row_6[b8e82d64-eaf9-4bfc-b955-f63cf4f8811d, 1] 
row_7[58ed7634-142f-4e70-83ee-1579ec9dfd62, 1] 
row_8[b2e41ac5-2ab9-49ca-ba27-f2b53d5fde9c, 1]

This dataset is given to setSecuritySettings and the uuids are for Forms or for Elements. But both dose not work! But the Forms should only be viewable but they are editable. And I don’t understand why.

Regards, Stef

Hi Stef,

Stop searching. I’ve noticed that the authenticator module returns a damaged JSDataset object :? . Through debugging I saw the dataset ok in de auth. module but somehow changed when received in de login module.

I use a Javascript object now, that works fine…

Regards,

ues, we have seen that too!

dataset, from authenticator to login, get screwed.
as a workaround, we convert the dataset to an array, and all is fine.

lwjwillemsen:
the authenticator module returns a damaged JSDataset object

We just discovered that ourselves, this is fixed in release 5.2.5

Rob