Blog moved
September 10th, 2005
My Blog has been moved… This is the new url: http://blogs.southworks.net/blogs/matiaswoloski
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!
}
Exception Logging to Email Sink
March 31st, 2005
Send an email when an exception is thrown using EntLib is not rocket science.
Here is a screen shot of how the configuration looks like
The steps involved are:
- Create an Exception Handling App Block
- Create a New Policy (for instance “Email Policy“)
- Create a new type of Exception to manage on the policy. Using “Exception“ will catch every kind of exception thrown
- Create a new Logging Handler for the Exception. Here the Logging and Instrumentation App Block will be added to the config.
- Add the Email Sink on the Logging Block and configure it (from and to email address, etc).
- Create a new Category (for instance “Several“) and add a new Destination
- Configure the Destintation to use the Text Formatter and the Email Sink
- Go to the Logging Handler node and set the LogCategory to “Several“
Here are the config files ExceptionLoggingToEmail.zip (2.91 KB)
Btw, sending an email is a task that requires some resources so
maybe It would be better to use the Async Logging as I described in the
last post. And let the distributor service to send the exception email in another process or server.