AzMan EntLib - operation and tasks
April 12th, 2005
AzMan could define operations, tasks and roles. You can use operations and tasks from entlib.
Here you have a small AzMan wrapper class that will encapsulate how to use AzMan from EntLib
Note: this code is not tested nor compiled. It is provided as-is.
public class AzMan {
public static bool CheckOperation( string operation, IPrincipal principal ) {
return Check ( “O:” + operation, principal );
}
public static bool CheckTask( string task, IPrincipal principal ) {
return Check ( task, principal );
}
private static bool Check( string context, IPrincipal principal ) {
IAuthorizationProvider authzProv = AuthorizationFactory.GetAuthorizationProvider(“AzManProvider”);
bool isAuthorized = authzProv.Authorize( principal, context );
return isAuthorized;
}
}
WindowsPrincipal principal = new WindowsPrincipal( WindowsIdentity.GetCurrent() );
if ( AzMan.CheckOperation( “PayBill”, principal ) {
// principal can do operation PayBill
} else {
// ERR!
}
if ( AzMan.CheckTask( “TransferFunds”, principal ) {
// principal can do task TransferFunds
} else {
// ERR!
}