Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Lock program for user

Former Member
0 Likes
1,184

Hi Gurus!

I would like to know if there is a way to lock a program just for one user, but no for other users.

I´ve been looking but found nothing.

Hope you can help me.

Thanks,

Jocelyne

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,154

Hi Jocelyne,

It feels like you need to apply the authorisation concept. In the initialisation of the program make an authorisation check against a unique authorisation object (one that is not used elsewhere), if the check fails the program exits.

As you want everyone to run this apart from one user it may be easier to reverse the usual logic. Perform the authorisation check, if the check fails, carry on, if it is successful then exit. THen you only need to give the role which has the object checked to one user (the one who shouldn't access the program) rather than to everyone.

Regards,

Nick

9 REPLIES 9
Read only

Former Member
0 Likes
1,155

Hi Jocelyne,

It feels like you need to apply the authorisation concept. In the initialisation of the program make an authorisation check against a unique authorisation object (one that is not used elsewhere), if the check fails the program exits.

As you want everyone to run this apart from one user it may be easier to reverse the usual logic. Perform the authorisation check, if the check fails, carry on, if it is successful then exit. THen you only need to give the role which has the object checked to one user (the one who shouldn't access the program) rather than to everyone.

Regards,

Nick

Read only

0 Likes
1,154

Thanks Nick, but I think I was not cleared.

All users can access the program, but what I want, is that if I am using the program, I shouldn´t run other window with the same program. Like I could only run it once.

But if other user wants to run it, there should not be a problem. But he could only run it once.

Is that possible?

Read only

0 Likes
1,154

Hi,

Ah, I understand now.

I guess I would use a custom table and a lock object. When the user first runs the program, add their user name to the custom table and lock this row of the table using a lock object. If the lock fails, it's because the user is already running the program. The reason for using the lock object is however the user closes the transaction the lock is released, if you just rely on the user name in the table it will not get cleared in all cases.

There are probably other viable approaches, and no doubt shortcomings with this suggestion, but it feels like you'll need to develop something.

Regards,

Nick

Read only

0 Likes
1,154

What happens if the program abends or the system crashes?

Rob

Read only

0 Likes
1,154

What do you mean? If the system crashes and it was running the program, it should be like other standard programs.

Sorry, I dont understand your question, Rob.

Read only

0 Likes
1,154

I just meant that if the program is dependent on an entry being added at the start and removed at the end, problems would happend if the program abended and the entry not be removed.

But I'm not sure if that was what Nick meant.

Rob

Read only

0 Likes
1,154

Hi Rob,

If the program abends or the system crashes the lock will roll back. Next time the user runs the program the entry with their name is still in the table, but that is not an issue.

The program will try to add the entry, it's already there (no error handling needed), then it it will lock that entry, the lock is successful.

If they try to call the program for a second time, the program will try to add the entry, it's already there, then it will try to lock that entry and fail (already locked).

I'm probably missing something, but my feeling is it will work.

Regards,

Nick

Read only

0 Likes
1,154

Yes - that should work. I didn't read your original post closely enough

Rob

Read only

0 Likes
1,154

Thank you guys, I am gonna try your ideas and let you know! 😃