AS

Hi,

Is it possible change user permissions / make him admin in time of script (macro/report) running ? I need to give to user option to write into the locked group/only for admin group.

Thanks.

by Ariene Kroeze
Posted on Thu, 03/24/2016 - 10:41

The best way to solve this issue is to open the active database again (in and by the script), with an user that has admin rights and use this db object for your admin activities.  The name and password of the admin user can be stored in a xml-file or in the script itself.

0
by Albina Schupak Author
Posted on Thu, 03/24/2016 - 10:53

In reply to by Ariene Kroeze

I tried to open the database with admin, but the script did not respond on it. I still have got the same active user. I used

ArisData.openDatabase(gActiveDB.Name(lng), "user", "password", "filterGUID", lng) function for it. Am I right? Do you have some suggestions? I work with Aris 9.

Thanks.

0
by Ariene Kroeze
Posted on Fri, 03/25/2016 - 13:53

After you opened the database you have two (2) db objects:

1: oDB1 = ArisData.getActiveDatabase()

2: oDB2 = ArisData.openDatabase(gActiveDB.Name(lng), "user", "password", "filterGUID", lng)

with oDB1 you only have the rights of the actual user (ArisData.getActiveUser())

with oDB2 you have the rights of the (admin)user that opened thi 2nd DB-object.

So if you want to create a model via the first db-object (oDB1) in a goup where the actual user doesn't have rights, it will fail, but via oDB2 you will succeed:

for example:

var oGroup = oDB2.Find(Constants.SEARCH_GROUP, Constants.AT_NAME, gnLoc, "GroupName", Constants.SEARCH_CMP_EQUAL)

var oModel = oGroup.createModel(Constants.MT_EEPC, "ModelName", gnLoc)

etc....

 

 

0
by Albina Schupak Author
Posted on Sun, 03/27/2016 - 13:31

In reply to by Ariene Kroeze

Oh, I see. It did work smoothly but may I ask another one question? In this case I have a problem with last change and last user. I need to keep them accordingly to user who runs the report.

Thank you a lot.

0
by Ariene Kroeze
Posted on Sun, 03/27/2016 - 20:08

Database.setAutoTouch(boolean p_bEnableTouch)

p_bEnableTouch:

  • True:  (default behavior): each time a change happens the attributes last modifier (last user)/last modification date are set
  • False:  attributes last modifier (last user)/last modification date are not set automatically

 

0
by Albina Schupak Author
Posted on Mon, 03/28/2016 - 13:46

In reply to by Ariene Kroeze

Thanks a lot for your answers.

I work with this function a lot but in this case the active user does not perform any actions, so it's nothing updates. All changes have to be updated with his name.

Thanks.

0
by Ariene Kroeze
Posted on Mon, 03/28/2016 - 20:35

What you can do is to perform the 'admin like' actions with the autotouch off, in the db(object) that is opened with the 'admin' rights' and after that you save the model (or what object it might be) in the standard db (object).

Or.... (but I don't know if that will be possible), set autotouch off and set the value for attributes for last change date and last user manually with the data of your 'normal' user.

0
by Albina Schupak Author
Posted on Tue, 03/29/2016 - 13:44

In reply to by Ariene Kroeze

Hi,

The second solution does not seem working, the first one I did not understand. For example: I moved some models into the group with no permissions for active user. How can I update last user attribute? I tried to make change of model name prior the model moving but for some reason nothing happened.

I'm waiting for your advice. Thanks again.

0
by Kobus Viljoen
Posted on Tue, 03/29/2016 - 17:05

In reply to by zalbina

Good day,

After changing the model with the admin user you could open the model with the active user again and use item.Touch() to update last change and last user attributes. I'm not sure if this will work if the active user has limited access to the model or if the model is locked.

Regards.

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Tue, 03/29/2016 - 08:34

Hi,

it's possible to set the last change date and last user via script...

BR Robert

0
by Ariene Kroeze
Posted on Tue, 03/29/2016 - 18:13

Hereby a little script that you can run on a model. In my case the active user has only read writes, the admin user has all access rights of course.

With this script you can use each name (not necessarily of an existing user) as last user.



function main(){

   

    var oDB1 = ArisData.getActiveDatabase()   

    var oModel1 = ArisData.getSelectedModels()[0]

    var sGUID = oModel1.GUID()

    Dialogs.MsgBox("'Last user name' = " + oModel1.Attribute(Constants.AT_LUSER,-1).getValue())

   

    var oDB2= ArisData.openDatabase(oDB1.Name(-1), "system", "manager", "dd838074-ac29-11d4-85b8-00005a4053ff", -1)

    var oModel2 = oDB2.FindGUID(sGUID, Constants.CID_MODEL)

    var sLastUserName = Dialogs.InputBox ("Input name to use as 'last user name'", "Test 'last user name'","")

    if (sLastUserName>""){       

        oDB2.setAutoTouch(false)

        oModel2.Attribute(Constants.AT_LUSER,-1).setValue(sLastUserName)

        oDB2.setAutoTouch(true)

        oDB2.close()

    }

    Context.addActionResult (Constants.ACTION_UPDATE, "", oModel1) // without this line you have to reload the model yourself to see the update

}

main()

0
by Albina Schupak Author
Posted on Wed, 03/30/2016 - 10:07

In reply to by Ariene Kroeze

Thank you very much for your so detail code. It does work for me in case when I write the setAutoTouch(false) line right after admin database opening otherwise it did not. It's weird but the mistery is solved. Thank you very much again.

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock