Topic
  • 6 replies
  • Latest Post - ‏2019-06-12T10:21:37Z by Juanfergar
Juanfergar
Juanfergar
21 Posts

Pinned topic Get the permissions in a module

‏2019-06-11T07:06:07Z | access permissions

Hello,

 

I want to get the module's access to know which users and groups have access to the module. I know how to do it for the attributes, views, types,...but not for the module's access.

 

Thank you!

  • Mike.Scharnow
    Mike.Scharnow
    586 Posts
    ACCEPTED ANSWER

    Re: Get the permissions in a module

    ‏2019-06-12T07:06:21Z  

    Thank you for the answer.

     

    I know how to go throw every access, but I don't know how to print them. In the example show the name of the user ("string user = username ar")  but if the access is for a group I can't print it. Or if the access is "Everyone else" neither.

     

    An example of what I did is:

     

    Module m = ...
    AccessRec ar
    int i = 0
    for ar in m do{
        i++
        print i "\n"
    }
    

    But never print 

    Something like this should work:
    
    
    for ar in m do {
        string userOrGroup = username ar
        if (null userOrGroup) {
            print "Everyone Else: "
        } else {
            if (existsGroup (userOrGroup)) {
                print "Group " userOrGroup ": "
            } else {
                print "User " userOrGroup ": "
            }
        }
        if (modify ar) {
            print "can modify\n"
        } else {
            print "cannot modify\n"
        }
    }
    

    For sanity, you could add a condition if not existsUser (userOrGroup) to find accessrecordsr for deleted users/groups. Should not occur.

    Updated on 2019-06-12T07:07:57Z at 2019-06-12T07:07:57Z by Mike.Scharnow
  • Mike.Scharnow
    Mike.Scharnow
    586 Posts

    Re: Get the permissions in a module

    ‏2019-06-11T21:19:52Z  

    I don't understand - there is no difference between AccessRecs of attributes and modules.

     

    So, a simple 

    AccessRec ar; Module m = ...; for ar in m do {...}
    

    should do the trick.

  • Juanfergar
    Juanfergar
    21 Posts

    Re: Get the permissions in a module

    ‏2019-06-12T06:19:02Z  

    I don't understand - there is no difference between AccessRecs of attributes and modules.

     

    So, a simple 

    <pre class="javascript dw" dir="ltr">AccessRec ar; Module m = ...; for ar in m do {...} </pre>

    should do the trick.

    Thank you for the answer.

     

    I know how to go throw every access, but I don't know how to print them. In the example show the name of the user ("string user = username ar")  but if the access is for a group I can't print it. Or if the access is "Everyone else" neither.

     

    An example of what I did is:

     

    Module m = ...AccessRec ar
    int i = 0
    for ar in m do{
        i++
        print i "\n"
    }
    

    But never print 

    Updated on 2019-06-12T06:23:17Z at 2019-06-12T06:23:17Z by Juanfergar
  • Mike.Scharnow
    Mike.Scharnow
    586 Posts

    Re: Get the permissions in a module

    ‏2019-06-12T07:06:21Z  

    Thank you for the answer.

     

    I know how to go throw every access, but I don't know how to print them. In the example show the name of the user ("string user = username ar")  but if the access is for a group I can't print it. Or if the access is "Everyone else" neither.

     

    An example of what I did is:

     

    <pre class="javascript dw" dir="ltr">Module m = ...AccessRec ar int i = 0 for ar in m do{ i++ print i "\n" } </pre>

    But never print 

    Something like this should work:
    
    
    for ar in m do {
        string userOrGroup = username ar
        if (null userOrGroup) {
            print "Everyone Else: "
        } else {
            if (existsGroup (userOrGroup)) {
                print "Group " userOrGroup ": "
            } else {
                print "User " userOrGroup ": "
            }
        }
        if (modify ar) {
            print "can modify\n"
        } else {
            print "cannot modify\n"
        }
    }
    

    For sanity, you could add a condition if not existsUser (userOrGroup) to find accessrecordsr for deleted users/groups. Should not occur.

    Updated on 2019-06-12T07:07:57Z at 2019-06-12T07:07:57Z by Mike.Scharnow
  • Juanfergar
    Juanfergar
    21 Posts

    Re: Get the permissions in a module

    ‏2019-06-12T08:38:57Z  
    <pre class="javascript dw" dir="ltr">Something like this should work: for ar in m do { string userOrGroup = username ar if (null userOrGroup) { print "Everyone Else: " } else { if (existsGroup (userOrGroup)) { print "Group " userOrGroup ": " } else { print "User " userOrGroup ": " } } if (modify ar) { print "can modify\n" } else { print "cannot modify\n" } } </pre>

    For sanity, you could add a condition if not existsUser (userOrGroup) to find accessrecordsr for deleted users/groups. Should not occur.

    That seems perfect, but now my problem is that neve enter in the for, I mean, in my example:

    Module m = ...
    AccessRec ar
    int i = 0
    for ar in m do{
        i++
        print i "\n"
    }
    

    Print nothing, because doesn't enter in the for.

  • Mike.Scharnow
    Mike.Scharnow
    586 Posts

    Re: Get the permissions in a module

    ‏2019-06-12T10:10:19Z  

    That seems perfect, but now my problem is that neve enter in the for, I mean, in my example:

    <pre class="javascript dw" dir="ltr">Module m = ... AccessRec ar int i = 0 for ar in m do{ i++ print i "\n" } </pre>

    Print nothing, because doesn't enter in the for.

    That means that your module has no own access records (Module -> Properties -> Access -> Inherit from parent = true), i.e. the module inherits the access rights from its parent.

    You can check this with the perm 

    string isAccessInherited(Module m,[AttrType at,]bool &inherited)
    

    If you want to see the effective access rights, you can use the loop

    
    
    
    
    

     

    By the way: see http://www.smartdxl.com/content/?p=388 and http://www.smartdxl.com/content/?p=385 for scripts dealing with access rights.

     

    Update: hm, seems that the screenshot is not shown correctly. The loop is "for ar in all item", (page 475 of the reference manual)

     

    Updated on 2019-06-12T10:14:08Z at 2019-06-12T10:14:08Z by Mike.Scharnow
  • Juanfergar
    Juanfergar
    21 Posts

    Re: Get the permissions in a module

    ‏2019-06-12T10:21:37Z  

    That means that your module has no own access records (Module -> Properties -> Access -> Inherit from parent = true), i.e. the module inherits the access rights from its parent.

    You can check this with the perm 

    <pre class="javascript dw" dir="ltr">string isAccessInherited(Module m,[AttrType at,]bool &inherited) </pre>

    If you want to see the effective access rights, you can use the loop

    <pre class="javascript dw" dir="ltr"> </pre>

     

    By the way: see http://www.smartdxl.com/content/?p=388 and http://www.smartdxl.com/content/?p=385 for scripts dealing with access rights.

     

    Update: hm, seems that the screenshot is not shown correctly. The loop is "for ar in all item", (page 475 of the reference manual)

     

    Perfect! It was because all the modules I was checking were with Inherit. So with this and your answer before I can know all the permissions in the modules.


    Tank you!!!