IsInRole(AuthorizationActions, params string[] roles) in CSLA 4.2

IsInRole(AuthorizationActions, params string[] roles) in CSLA 4.2

Old forum URL: forums.lhotka.net/forums/t/11198.aspx


maxdrive posted on Monday, February 27, 2012

Hi,

I'm using CSLA 4.2 and the above subject is not working on my PC when i put something on the roles part. Did i miss something?

Below are sample code snippets:

protected static void AddObjectAuthorizationRules()

{

    Csla.Rules.BusinessRules.AddRule(typeof(SomeClass), new Csla.Rules.CommonRules.IsInRole(AuthorizationActions.EditObject, "Foo"));

}

class AuthRule : AuthorizationRule

{

public AuthRule(AuthorizationActions action) : base(action)

{

}

 

protected override void Execute(AuthorizationContext context)

{

 

 

context.HasPermission = true;

 

 

 

 

 

 

}

}

JonnyBee replied on Monday, February 27, 2012

The EditObject authorization is only checked by the DataPortal when calling Save on an existing object.

 

maxdrive replied on Monday, February 27, 2012

Hi JB,

Yes that's correct but my problem is when i place something on the roles part (2nd parameter), i.e. "Foo", seems like not working because the link to edit is not enabled. The system checks the role entered during log in and it will check again the role if it is allowed for editing. I have to check my code again though.

Thanks.

Copyright (c) Marimer LLC