Topic
  • 2 replies
  • Latest Post - ‏2019-05-26T02:05:58Z by Gsquare
Gsquare
Gsquare
55 Posts

Pinned topic DXL not working:Remove users with "none" aceess to a module

‏2019-05-21T07:29:34Z |

Hi,

 

I want to remove from all items in the current folder, all users who have "None" access to the items.

Here is my code, i am able to modify the rights of a user to "None", but not able to remove him, from the list of users who have access.

i am getting error in this line :

removeUser(username(ar))

 

 

void recurseFolders( Item parentItem )
{
   string itemType = type( parentItem )

   if ( ( itemType == "Folder" ) || ( itemType == "Project" ) )
    {
          Item childItem
          for childItem in folder( parentItem ) do
        {
             recurseFolders( childItem )
          }
       }

                  // print itemType ":\t"
                //print fullName( parentItem ) "\t" uniqueID( parentItem ) "\n"


   AccessRec ar
   Permission p
   for ar in all parentItem do
   {

      if ( isDefault( ar ) )
    {
         //print "\tDefault"
      }
      else
    {
      if(existsUser(username(ar)))
      {

        if(username(ar) == "aab1pg1")
          {
        
        
          print "\t" username( ar )
        print " ("
          string r = ((read ar) ? "R" : "")
          string m = ((modify ar) ? "M" : "")
          string c = ((create ar) ? "C" : "")
          string d = ((delete ar) ? "D" : "")
          string a = ((control ar) ? "A" : "")

          string accessStr =  r m c d a ""
          if ( null accessStr ) accessStr = "None"
          print accessStr
          print ")"
          print "\n"


        
          //p = none
              //set(parentItem,p,username(ar))
        removeUser(username(ar))

        }

        }
      
    }
      

   }


}

recurseFolders(item(fullName current Folder))

 

Updated on 2019-05-21T12:08:32Z at 2019-05-21T12:08:32Z by Gsquare
  • llandale
    llandale
    3088 Posts
    ACCEPTED ANSWER

    Re: DXL not working:Remove users with "none" aceess to a module

    ‏2019-05-23T00:42:42Z  

    You should say what the error is.  In this case its "Incorrect argumenst for function (removeUser)" yes?

    Looking at the DXL manual I see that "removeUser" is a Discussion thing.

    You want the "unset" command in DXL manual chapter "Access controls" section "Controlling access":
    string unset({Object o|Project p|Module m| Folder f|Item i|View v|Group g}, [AttrType at,] {string user|string group})

    that would look like:|  string ErrMess = unset(parentItem, username(ar))

     

    But wait!! If you remove the "ar" you may mess up the "for ar in all parentItem do" loop.  So instead:

    Skip skpArsToRemove = create()

    .... put(skpArsToRemove(at, at)   // instead of unset

    Then add this:

    for ar in skpArsToRemove do

    { string ErrMess = unset(parentItem, username(ar))

    }

    delete(skpArsToRemove

    -Louie

     

     

  • llandale
    llandale
    3088 Posts

    Re: DXL not working:Remove users with "none" aceess to a module

    ‏2019-05-23T00:42:42Z  

    You should say what the error is.  In this case its "Incorrect argumenst for function (removeUser)" yes?

    Looking at the DXL manual I see that "removeUser" is a Discussion thing.

    You want the "unset" command in DXL manual chapter "Access controls" section "Controlling access":
    string unset({Object o|Project p|Module m| Folder f|Item i|View v|Group g}, [AttrType at,] {string user|string group})

    that would look like:|  string ErrMess = unset(parentItem, username(ar))

     

    But wait!! If you remove the "ar" you may mess up the "for ar in all parentItem do" loop.  So instead:

    Skip skpArsToRemove = create()

    .... put(skpArsToRemove(at, at)   // instead of unset

    Then add this:

    for ar in skpArsToRemove do

    { string ErrMess = unset(parentItem, username(ar))

    }

    delete(skpArsToRemove

    -Louie

     

     

  • Gsquare
    Gsquare
    55 Posts

    Re: DXL not working:Remove users with "none" aceess to a module

    ‏2019-05-26T02:05:58Z  
    • llandale
    • ‏2019-05-23T00:42:42Z

    You should say what the error is.  In this case its "Incorrect argumenst for function (removeUser)" yes?

    Looking at the DXL manual I see that "removeUser" is a Discussion thing.

    You want the "unset" command in DXL manual chapter "Access controls" section "Controlling access":
    string unset({Object o|Project p|Module m| Folder f|Item i|View v|Group g}, [AttrType at,] {string user|string group})

    that would look like:|  string ErrMess = unset(parentItem, username(ar))

     

    But wait!! If you remove the "ar" you may mess up the "for ar in all parentItem do" loop.  So instead:

    Skip skpArsToRemove = create()

    .... put(skpArsToRemove(at, at)   // instead of unset

    Then add this:

    for ar in skpArsToRemove do

    { string ErrMess = unset(parentItem, username(ar))

    }

    delete(skpArsToRemove

    -Louie

     

     

    Thanks Louie, works perfectly