Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
arusanah
Creator II
Creator II

Section access script help for qliksense

 

I need help with section access script for qliksense. I have 3 groups: Group –A, Group-B, Group-C

. My requirement is to load all user from a qvd file. Check if osuser () belongs to one of these groups

 

//Implementing Security

//Section Access;
Authorization:
Load
'User'as Access,
  Group,
    GroupName,
    Upper(Group)&'\'&Upper(GroupName) as USERGROUP,
    objectCategory,
    objectClass,
    DistinguishedName,
    // subfield(subfield(DistinguishedName,'=',4),',',1)as Entity_Code,
     "cn" as UserID,
     Upper(Group)&'\'&Upper(GroupName)&'\'&"cn" as User,
    displayName as [Name]
FROM [lib://QVD/Raw\Active Directory\028_Raw_Active_Directory.qvd]
(qvd);


//Section Application;
NoConcatenate
Load * INLINE [
  USERGROUP,       Entity_Code
Group –A ,   *
  Group –B ,  B
Group –C,  C
];
Trace 'Autorization Loaded';

I tried two codes  but none of them works

*******************************  Code 1,


For i=0 to NoOfRows('Authorization')
Let vCount= NoOfRows('Authorization');
     Trace '$(vCount)';-------------------------------------------------Till this point it works fine.
if exists(osuser(),USERGROUP) then
      Let vEntity=Lookup('Entity_Code','UserGroup',OSUSER(),'Authorization');
        Trace '$(vEntity)';
    End If

Next;

*******************************Code 2,

For i=0 to NoOfRows('Authorization')

Let vCount= NoOfRows('Authorization');

    Let vUser=subfield(OSUser(),'=',3);

if(UserID='$(vUser)')then

      //Let vEntity=Lookup('Entity_Code','USERGROUP',UserID,'Authorization');

        Trace 'yes';

    End If

   

Next

But when I try to trace vEntity it shows nothing . Issue is within red piece of code .which I'm not able to replicate

 

8 Replies
mikaelsc
Specialist
Specialist

osuser() is useless in qlik sense (and i'm not even sure it's a script function)

jonathandienst
Partner - Champion III
Partner - Champion III

>>But when I try to trace vGroup it shows nothing


Where and when was vGroup defined to anything. If undefined, $(vGroup) will be null.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
arusanah
Creator II
Creator II
Author

Hi Jonathan ,

I meant vEntity. I did some modification. in code , please take a look . I will really Appreciate if you can help.

arusanah
Creator II
Creator II
Author

//Section Access;

Authorization:

Load

'User'as Access,

  Group,

    GroupName,

    Upper(Group)&'\'&Upper(GroupName) as USERGROUP,

    objectCategory,

    objectClass,

    DistinguishedName,

    // subfield(subfield(DistinguishedName,'=',4),',',1)as Entity_Code,

     "cn" as UserID,

     Upper(Group)&'\'&Upper(GroupName)&'\'&"cn" as User,

    displayName as [Name]

FROM [lib://QVD/Raw\Active Directory\028_Raw_Active_Directory.qvd]

(qvd);

//Section Application;

NoConcatenate

Reduction:

Load * INLINE [

  USERGROUP,       Entity_Code

        GrpA\GROUP-A,  A

        GrpB\GROUP-B, B

        GrpC\GROUP-C,  C

];

Trace 'Autorization Loaded';

Let vEntity=Lookup('Entity_Code','USERGROUP',UserID,'Authorization'); ------can anybody help replicate issue in this lookup function --------------

Trace '$(vEntity)';

mikaelsc
Specialist
Specialist

you don't find out. one of the services does (i guess the proxy service)

what you need to do:

-create an application containing all your data (of all your entities)

- add a section access table containing the link between users and the entities

- reload the app

on opening, a user will only be able to see what the section access table defined he's allowed to see (but the application itself contains ALL the data)

https://help.qlik.com/en-US/sense/2.1/Subsystems/Hub/Content/Scripting/Security/sections-in-script.h...

mikaelsc
Specialist
Specialist

sorry, the most relevant ressource is the dynamic data reduction one :

https://help.qlik.com/en-US/sense/2.1/Subsystems/Hub/Content/Scripting/Security/dynamic-data-reducti...

arusanah
Creator II
Creator II
Author

Thanks Mikael. I already  found out error in script.

arusanah
Creator II
Creator II
Author

so error as I already knew was in my Lookup function .

//Section Access;

Authorization:

Load

'User'as Access,

  Group,

    GroupName,

    Upper(Group)&'\'&Upper(GroupName) as USERGROUP,

    objectCategory,

    objectClass,

    DistinguishedName,

    // subfield(subfield(DistinguishedName,'=',4),',',1)as Entity_Code,

     "cn" as UserID,

     Upper(Group)&'\'&Upper(GroupName)&'\'&"cn" as User,

    displayName as [Name]

FROM [lib://QVD/Raw\Active Directory\028_Raw_Active_Directory.qvd]

(qvd);

//Section Application;

inner Join

Reduction:

Load * INLINE [

  USERGROUP,       Entity_Code

        GrpA\GROUP-A,  A

        GrpB\GROUP-B, B

        GrpC\GROUP-C,  C

];

Trace 'Autorization Loaded';

*************************** I replaced that witjh this new small piece of code and it works fine**********

let vUser= SubField( SubField(OSuser(),';',-1),'=',-1);

let vEntity = Lookup('Entity_Code','UserID',SubField( SubField(OSuser(),';',-1),'=',-1),'Reduction');

Trace '$(vUser)';

Trace '$(vEntity)';