I'm sure this is a common question, or rather the answer is widely known...
But I would like to implement some authorization rules based on the state of my BO in conjunction with a role.
So, I'd like to do something like...
If Me.isNew = False Then
AuthorizationRules.DenyWrite(
"PHONE", "SALES") End ifIn this scenario, I do not want "SALES" to be able to edit a phone number if an object is not new. Could someone enlighten me as to the "correct" way of doing this? I suspect the above neither works nor is considered OO...
Many thanks,
Gaj.
So I override the CanWriteProperty in my business object?
Now sure I know how to implement that.. wouldn't the remainder of my properties use the same overridden method?
Confused.... :(
Sorry,
G.
OK, I think I've got it (Holmes!) :)
In my BO..
Public Overrides Function CanWriteProperty(ByVal propertyName As String) As Boolean If Me.IsNew And propertyName = "PHONE" Then Return False Else Return MyBase.CanWriteProperty(propertyName) End If End FunctionThanks Brian!
Public Overrides Function CanWriteProperty(ByVal propertyName As String) As Boolean
Select Case propertyName
Case "PHONE"
Return IsNew Or Not Csla.ApplicationContext.User.IsInRole("SALES")
End Select
End Function
Copyright (c) Marimer LLC