new security feature

if I do this:

var a = security.getUserId()
groep = security.getUserGroups(a)

I’ll get as result:

JSDataSet:rowIndex-1

what I want is the groupname of the current user
What am I doing wrong?

P.S. Is it possible to have functions like: setUsername(groupname)?

Sorry, that was my message, forgot to login!

That output string prints the selected row of a jsdataset. (no row is selected)

i have changed that output so that it prints now:
JSDataSet:size:1,selectedRow:-1

try to output:
application.output(dataset.getMaxRowIndex());

and you will see that it will return a number > 0

sorry, I do not completly understand.

with the example I have given, it must return a groupname like: Administrators.
Or am I wrong?

ahh sorry
look at the security node in the tree. There you see a extra node below it that is a list with returntypes (currently just one JSDataSet)
and if you look at the method call:

security.getUserGroups(a);

you see that getUserGroups returned a JSDataSet object

so on youre groep variable you can call:

groep.getMaxRowIndex();
or
groep.getValue(row,column);

for every function you can call on groep see the node under the security node.

I am sorry, but the light :idea: is not blinking :oops:
Can you give some more examples on how to use this feature, for example:
how can I add a new user to a specific group?
how can I retrieve information of a user?

I think I need some more coffee :? to be sharp! :lol:

Does anybody know how this works.?
I am getting stuck here! :(

HJK:
Does anybody know how this works.?
I am getting stuck here! :(

I think what is being explained is the following.

Some of the functions in Servoy return a data set. In this case the data set is a JavaScript data set. This means, what is returned is an array. You then have to use JavaScript to work code against the data set. Pulling out values for comparisons, etc.

When a data or row index of -1 is returned then this means a zero found set. It looks like you need to be logged into the system in order to get a return from the new security features. Since working with Developer means you don’t have to log in you will get return values that aren’t that useful for testing.

This means for some features you will need to log into a client version to test your features.

Unless the programmers add in a feature where you can “emulate” a login, while in Developer, there are some things that will require testing through a client.

Of course, I could be completely wrong and I’m sure I’ll be corrected by one of the Servoy folks.

I think you have to log into develloper as well as client. But first you have to set the “Login required” flag under security to “yes” and create user etc.

for the solutions i created with a logon required, I also have to login in develloper.

Also, I use functions so log every session of my solution in a table. For that I used to use the “get username” command, to write the user name in a text field.

All my develloper sessions are tracked as well, so that also tells me that in develloper these functions are available

I hope some of the Servoy-guys can give us more examples.
This is a totaly grey-area for me!

Try this:

var set = security.getUserGroups()
elements.test.text = ‘’+set.getAsHTML()+‘’;
//elements.test.text = set.getValue(1,2)

Test = the name of a label on a form

The -1 means there are no results

The sample code for the GetDatasetByQuery function gives a good example how to loop through a dataset and evaluate the dataset and take action based on the results of the evaluation.

Adding users/usergroups etc is not available as far as I know, but I’m sure it’s on “the List” :D

Here another example

var o = security.getUsers()
for(var i=1 ; i<=o.getMaxRowIndex() ; i++)
{
application.output(“user:” + o.getValue(i,2));
var p = security.getUserGroups(o.getValue(i,1));
for(k=1;k<=p.getMaxRowIndex();k++)
{
application.output("group: " + p.getValue(k,2));
}
}