Is there any function to check element security in VBA

Post Reply
kennyyeung
Posts: 19
Joined: Fri May 15, 2009 12:44 pm
Version: 9.4 MRC
Excel Version: 2000

Is there any function to check element security in VBA

Post by kennyyeung »

Dimension : Customer have apply security issue .User can only see their own customer .
But when i coding in VBA , the code below will return a full set of customer (including those with no permission)
is there any function to check the element security to filter those customer with no permission?


custSize = Application.Run("DIMSIZ", "gpdev:Customer")
For i = 1 To custSize
custName = Application.Run("DIMNM", "gpdev:Customer", i)
value = Application.Run("DBR", "gpdev:UserCustomerMapping", tm1User, custName, "Value") < ---Error because no permission on customer
next
User avatar
Martin Ryan
Site Admin
Posts: 1989
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Is there any function to check element security in VBA

Post by Martin Ryan »

Hi Kenny,

According to your profile you're running version 9.4, which surprises me as I thought this was an issue from several versions ago, that they'd fixed up.

As for as a workaround, there's no easy VBA macro. For your particular bit of code I would suggest you do some error catching that means the error is invisible to the user.

More generically when I came across this error I would test the user's access to an attribute against the dimension. If that errored then I would handle it appropriately.

Regards,
Martin
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Alan Kirk
Site Admin
Posts: 6644
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Is there any function to check element security in VBA

Post by Alan Kirk »

kennyyeung wrote:Dimension : Customer have apply security issue .User can only see their own customer .
But when i coding in VBA , the code below will return a full set of customer (including those with no permission)
is there any function to check the element security to filter those customer with no permission?


custSize = Application.Run("DIMSIZ", "gpdev:Customer")
For i = 1 To custSize
custName = Application.Run("DIMNM", "gpdev:Customer", i)
value = Application.Run("DBR", "gpdev:UserCustomerMapping", tm1User, custName, "Value") < ---Error because no permission on customer
next
Kenny, there is a workaround that you may want to consider. Rather than looping through the whole dimension, create an MDX public subset which contains only the N level elements, then loop through that instead. This should only return the elements that they can see, though it doesn't work if you use the All subset. See LotsaRam's post (the third last one) in this thread for the whys and wherefores: http://forums.olapforums.com/viewtopic. ... 919&p=5319
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
kennyyeung
Posts: 19
Joined: Fri May 15, 2009 12:44 pm
Version: 9.4 MRC
Excel Version: 2000

Re: Is there any function to check element security in VBA

Post by kennyyeung »

I am using version 9.4.
I can do it using TI .However It seem not yet fixed in VBA macro
Anyway ,Problem solved by using subset ..Thanks you !
Post Reply