Forum Discussion

hadi_r's avatar
hadi_r
New Contributor
3 years ago

Restricting access to force Consolidate

Hello,

is there a way to restrict users from force consolidating? Can we control who has access to force consolidate in the system? 

 

Thanks,

Hadi 

  • ChristianW's avatar
    ChristianW
    Valued Contributor

    Please check here: https://community.onestreamsoftware.com/t5/Accepted-Code-Samples/Event-Handler-for-Consolidate-with-orwithout-logging-or-Force/m-p/3688#M35

    With the si object you get the active user. Then you need to check, if the user is in a group of your choice, using a brapi function, to prevent or allow the force consolidate.

    There is a chancel flag to cancel silent, or you can use a brapi function to generated an error with a custom error message. Be careful, an error in the event handler prevents some functions to work.

     

  • ChristianW's avatar
    ChristianW
    Valued Contributor

    Hi Khanh, please contact you Onestream services contact or your partner (if you are a customer) to get the information. Regards Christian

  • Oscar's avatar
    Oscar
    Contributor

    Hi Khanh

    I just implemented something similar. You will need a Business Rule of type Wcf Event Handler

    Then the code is something like:

     Try

    ' OneStream provides the lines below
    Dim returnValue As Object = args.DefaultReturnValue
    args.UseReturnValueFromBusinessRule = False
    args.Cancel = False

    ' before consol starts
    If ( args.IsBeforeEvent And (args.WcfServiceType = WcfServiceType.Calculate Or args.OperationName= "StartConsolidation" Or args.OperationName= "StartProcessCube") )
    ' check if user is in security group OK_CONSOL if he is not then cancel running
    If ( Not brapi.Security.Authorization.IsUserInGroup(si,"OK_CONSOL")) Then
     args.Cancel = True
    ' throw in an exception to grab their attention
    Throw New XFException(si, New Exception("SOX Violation: User NOT Provisioned to Execute Consolidation."))
    End If
    End If
    Return returnValue

     

    • halbrooks100's avatar
      halbrooks100
      New Contributor III

      Do you create this as a new business rule? and where does it get stored? 

  • KhanhNguyen's avatar
    KhanhNguyen
    New Contributor II

    Hi Christian,

    I cannot access to your link, it's said "Access Denied. You do not have sufficient privileges for this resource or its parent to perform this action.".

    Could you kindly let me know how to access this resource please ?

    Thank you very much,

    Khanh

  • Oscar's avatar
    Oscar
    Contributor

    hello

    Yes, as a new business rule. OneStream will automatically save it under Extensibility Rules folder as WcfEventHandler. Do not chance the name or try to move the business rule. The code below is originally provided by OneStream at the time of creation

     

     

    Imports System
    Imports System.Collections.Generic
    Imports System.Data
    Imports System.Data.Common
    Imports System.Globalization
    Imports System.IO
    Imports System.Linq
    Imports System.Windows.Forms
    Imports Microsoft.VisualBasic
    Imports OneStream.Finance.Database
    Imports OneStream.Finance.Engine
    Imports OneStream.Shared.Common
    Imports OneStream.Shared.Database
    Imports OneStream.Shared.Engine
    Imports OneStream.Shared.Wcf
    Imports OneStream.Stage.Database
    Imports OneStream.Stage.Engine
    
    Namespace OneStream.BusinessRule.WcfEventHandler.WcfEventHandler
    	Public Class MainClass
    		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As WcfEventHandlerArgs) As Object
    			Try
    				Dim returnValue As Object = args.DefaultReturnValue
    				args.UseReturnValueFromBusinessRule = False
    				args.Cancel = False
    				
    				Dim wfScenarioName As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)
    				
    				BRApi.ErrorLog.LogMessage(si, $"DMx: {wfScenarioName}")
    
    				If (args.WcfServiceType = WcfServiceType.Calculate) Then
    					If args.OperationName.XFEqualsIgnoreCase("CalculateChartLogic") Then
    						If args.IsBeforeEvent Then
    							'Dim insertFailed as Boolean
    							'ErrorHandler.InsertErrorLogItem(si, XFErrorLevel.Information, "Before " + args.OperationName, XFTier.AppServer, String.Empty, String.Empty, String.Empty, insertFailed)
    						Else
    							'Dim insertFailed as Boolean
    							'ErrorHandler.InsertErrorLogItem(si, XFErrorLevel.Information, "After " + args.OperationName, XFTier.AppServer, String.Empty, String.Empty, String.Empty, insertFailed)
    						End If
    					End If
    				End If
    
    				Return returnValue
    			Catch ex As Exception
    				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    			End Try
    		End Function
    	End Class
    End Namespace