Page 1 of 1

Is there any function to check element security in VBA

Posted: Wed Jun 10, 2009 10:15 am
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

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

Posted: Wed Jun 10, 2009 10:55 am
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

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

Posted: Wed Jun 10, 2009 11:43 am
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

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

Posted: Wed Jun 10, 2009 11:58 am
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 !