7 Replies Latest reply on Sep 18, 2009 1:48 PM by Polarpro

    Get ( PrivilegeSetName ) produces wrong result in a script

    Polarpro

      Title

      Get ( PrivilegeSetName ) produces wrong result in a script

      Post

      Hey,

       

      I have a strange problem with a script. In one of my scripts, there is a line saying

       

      If [ Get ( PrivilegeSet ) <> "Edit_NonRestricted" ] 
      ...

       

      The Dataviewer shows for Get ( PrivilegeSetName )  "Edit_NonRestricted" as result, 

      and for the calculation Get ( PrivilegeSetName ) <> "Edit_NonRestricted" the result is 0;

       

      but the script treats this line as if the result was true

       

      I am utterly confused...

       

      Best regards,

      Mike 

        • 1. Re: Get ( PrivilegeSetName ) produces wrong result in a script
          mrvodka
             Are you running the script with Full Access.
          • 2. Re: Get ( PrivilegeSetName ) produces wrong result in a script
            Polarpro
              

            Bingo. Thank you.

             

            This means that Get ( PrivilegeSetName ) asks for the privileges of the script, but not the user's "actual" privilege set?

             

            Hm. It looks like I should use the account names to retrieve the actual privilege set. For this I usually use my User table. But this doesn't work either: There is a relationship MainTable::cGetAccountName=UserTable::AccountName, with cGetAccountName not being stored. Via this relationship I usually can retrieve the user's privilege set that is stored in the field UserTable:: PrivilegeSetOfUser. But in this case the result of this calculation is put in a field while in Find mode, and the Data Viewer shows that UserTable:: PrivilegeSetOfUser is empty when the script is in Finde mode.

             

            So, the question is how to use the user's account name to retrieve his actual privilege set without the User table. Any idea? 

            • 3. Re: Get ( PrivilegeSetName ) produces wrong result in a script
              ninja
                

              Howdy polarpro,

               

              I don't think it's as complicated as you might think.

               

              When the script runs with FullAccessPrivileges, that little checkbox overrides the actual account privileges when in the script.  Thus when you Get(PrivSetName), it returns "Full Access", regardless of the user.  Unchecking the box takes off the 'override' and looks at the actual user's PrivSet.

               

              As long as the box is unchecked, you should be in the clear.

               

              Round out this topic by looking at other posts on the forum about Get(PrivilegeSet)...there are a couple of other little quirks with it that may or may not apply to your situation.

              • 4. Re: Get ( PrivilegeSetName ) produces wrong result in a script
                Polarpro
                  

                Ninja,

                 

                Thanks, but for certain reasons I need to run the script with Full Access Privileges...

                • 5. Re: Get ( PrivilegeSetName ) produces wrong result in a script
                  ninja
                    

                  I never tried what I'm about to propose, so take it for what it is.  If there is an existing 'best practice', I hope that another will post what it is or a link to it.

                   


                  polarpro wrote:

                   for certain reasons I need to run the script with Full Access Privileges...


                   

                  You sure...?  It seems that only certain PARTS of the script need to be run with FullAccess.  What about separating them to pull out the part that can't be run under FullAccess?

                   

                  Script1: (does NOT run with FullAccess)

                  SetVariable ($$PrivSet ; Get(PriviligeSetName) )

                   

                  Script2: (Runs with FullAccess)

                  Beginning stuff

                  Perform Script (Script1)

                  If ($$PrivSet = "whatever")

                      Do this

                  EndIf

                   

                  Having not tried it, I don't know if the FullAccess would carry over to the other script or not.  If not...this would sure beat building a table architecture to carry all the info.

                  If the "FullAccess" carries over to the other script, you could sub out the FullAccess tasks to the other script and trap the variable before you enter a FullAccess Script.

                   

                  Just thinkin' out loud....

                   


                  • 6. Re: Get ( PrivilegeSetName ) produces wrong result in a script
                    comment_1
                       The sub-script could be as simple as:

                    Exit Script [ Result: Get ( PrivilegeSetName ) ]


                    Then in the main script, use:

                    Get ( ScriptResult )

                    instead of:

                    Get ( PrivilegeSetName )




                    • 7. Re: Get ( PrivilegeSetName ) produces wrong result in a script
                      Polarpro
                         <!--      StartFragment      -->

                      Hey comment and Ninja,

                       

                      Thank you for your input.

                       

                      Separating the script worked very well. The calling script does not override the setting of the subscript's privileges.

                       

                      I went for comment's suggestion to retrieve and pass on the name of the privilege set (as I try to avoid global variables).

                       

                      I've tested the solution, am very content. (And have learned a lot about running scripts with full access privileges 

                      Thanks again!

                       

                      Mike

                      <!--      EndFragment      -->